Template is not cleaning if i use compile to get data render multiple times.

1 view
Skip to first unread message

luqman paravetty

unread,
Aug 19, 2016, 10:08:02 AM8/19/16
to JavaScript Templates Engine PURE
Hi friends,

i dont know what's the issue while rendering data on clicking a button multiple times. i have used compile functionality also. Can anyone give a solution?

HTML:

<button onclick="aarappa()">HIT ME</button>

<div class="content" id="targetDigitalPriceSaved">
<div  style="float:left; ">
<table cellpadding="0" cellspacing="0" class="addListtable">
<tbody>
<tr>
<td class="cont num"><span class="num"></span> <span class="hidden" ></span></td>
<td class="cont compet"></td>
</tr>
</tbody>
</table>
</div>
</div>




JAVASCRIPT:

function aarappa(){
var dataDir = {
'table.addListtable tr':{
'retail<-':{
'span.num':function( a ){ 
return a.pos + 1 ; //concatenate the row number, a dot and the property who
},
'span.hidden':function( a ){ 
return a.pos  ; 
},
'td.compet': 'retail.retailer'
}
}
},

compiled = $('#targetDigitalPriceSaved').compile( dataDir ),
var data = [{"retailer":"AMZ","username":"","password":"","templates":[{"dpName":"BESTSELLER","dpDesc":"","dpType":"A","selectors":[{"selector":"","multiple":false,"elementType":"Text","regex":"","attribute":"","url":"","pageType":"PDP"}]}]},{"retailer":"AMZ","username":"","password":"","templates":[{"dpName":"BREADCRUMB","dpDesc":"","dpType":"A","selectors":[{"selector":"","multiple":false,"elementType":"Text","regex":"","attribute":"","url":"","pageType":"PDP"}]}]},{"retailer":"AMZ","username":"","password":""}];
$('#targetDigitalPriceSaved').render(data, compiled);

}

Mic (BeeBole)

unread,
Aug 19, 2016, 4:30:06 PM8/19/16
to JavaScript Templates Engine PURE
Hi Luqman,

Here is a working version of what you want to do: https://gist.github.com/beebole/c4fd9d325e83c86bb293e5f41acd165f 
  • the compilation must occur once and out of the repeated code
  • in the repeated code, the render is done with the compiled template
  • I've added a global variable that increase at each calls
Cheers,
-Mic
Message has been deleted

luqman paravetty

unread,
Aug 23, 2016, 9:15:05 AM8/23/16
to JavaScript Templates Engine PURE
Thank you so much Mic.
Reply all
Reply to author
Forward
0 new messages