Hi i am new to this Mustache.js I have a template and js code as below
var template = $('#pageTpl').html();
var html = Mustache.to_html(template, data);
$('#sampleArea').html(html);
and this is template code:
<script id="pageTpl" type="text/template">
<div data-role='page' id='videodiv_{{device_id}}'>
<div data-role=header>
<h1> Device Page </h1>
</div>
<div data-role=content>
<img id='vid_{{device_id}}' src='http://localhost//mjpg/{{device_id}}' width='320'>
</div>
</div>
</script>
this code works fine when i keep the template script in html page. but i want to keep template separately and use it. is there any way to do this?
Source: http://www.levihackwith.com/how-to-load-mustache-js-templates-from-an-external-file-with-jquery/