Nikhil Tikoo Nikhil Tikoo - 1 year ago 118
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download