Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple grids on page with cardTemplateString use the last template available #33

Merged
merged 1 commit into from
Mar 16, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
this.$$deckgrid = null;
this.transclude = true;
this.link = this.$$link.bind(this);

this.templateKeyIndex = 0;
}

/**
Expand All @@ -63,6 +65,8 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
*/
Descriptor.prototype.$$link = function $$link (scope, elem, attrs, nullController, transclude) {
scope.$on('$destroy', this.$$destroy.bind(this));

var templateKey = 'deckgrid/innerHtmlTemplate' + (++this.templateKeyIndex);

if (attrs.cardtemplate === undefined) {
if (attrs.cardtemplatestring === undefined) {
Expand All @@ -81,17 +85,17 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
}
}

$templateCache.put('innerHtmlTemplate', extractedInnerHTML.join());
$templateCache.put(templateKey, extractedInnerHTML.join());
});
} else {
// use the provided template string
//
// note: the attr is accessed via the elem object, as the attrs content
// is already compiled and thus lacks the {{...}} expressions
$templateCache.put('innerHtmlTemplate', elem.attr('cardtemplatestring'));
$templateCache.put(templateKey, elem.attr('cardtemplatestring'));
}

scope.cardTemplate = 'innerHtmlTemplate';
scope.cardTemplate = templateKey;
} else {
// use the provided template file
scope.cardTemplate = attrs.cardtemplate;
Expand Down