Does anyone know how to connect the data element used to render the jQuery template for the resulting dom object?
given this tmpl:
<script id="sectionTemplate" type="text/x-jquery-tmpl">
<div class="story-writer-section sticker ${CssClasses}">
<div class="title">
<div class="delete-button sticker-button"/>
${SectionName}
</div>
<div class="story-writer-story-container">
</div>
</div>
and this:
$("#sectionTemplate")
.tmpl(sections)
.appendTo(".story-writer-section-container");
I would like to attach each section to the result via .data ('section', data) in order to subsequently access all the data, because not all data is rendered, such as id, etc., which I need to get later when I do things like delete.
Maybe something like this ...
$("#sectionTemplate")
.tmpl(sections)
.appendTo(".story-writer-section-container").each(function (????) {
this.data('section', ?????);
});
But I have no idea how to get the current data item used to render this tmpl.
Is there a way for Perhpas to include this in the template itself?
Any help is greatly appreciated.
source
share