Nikhil Tikoo Nikhil Tikoo - 1 month ago 7x
Ajax Question

Stop rendering template in Handlebars

I have this small code that gets rendered the first time the page loads.

<div id="old-div">

Now the second time, an AJAX call happens and since first time the {{description}} and {{example}} are already filled, when i try to get the HTML of the template, instead of {{description}} and {{example}}, i get their values.

I don't want Handlebars to render the values to the expression when ajax call happens to that i can get the template and render new values.

Any help is appreciated.


Make a template, put it outside html <body> and use that to feed handlebars. You will be able to take it, feed handlebars and append to DOM with substituted values and retrieve the template itself (you can use <template> tag for it or <script> and add id attribute to reference it easily. That's how it's done on many websites.