javascript - Mustache.js within Django template not working -
i want render
ajax response mustache.js reason, variables inside templates aren't displayed. modified mustache's delimiter still isn't working.
.js
/* * reservation preview snippet. */ $(document).ready(function() { mustache.tags = ['<%', '%>']; var tablerows = $("#table-wrapper table tr"); // table row clicked tablerows.click(function(e) { e.preventdefault(); var $this = $(this); var previewurl = $(this).find("#ajax_id").attr('data-id'); // preview , load template $.getjson(previewurl, function(reservation) { console.log("updated at: " + reservation.updated_at); var template = $('#reservationpreviewtpl').html(); var html = mustache.render(template, reservation); console.log('html' + html); $('#test123').html(html); }); });
template
<div id="test123"></div> <script id="reservationpreviewtpl" type="text/template"> <h1>i template</h1> <p><% reservation.updated_at %></p> </script>
console output
turns out reservation.updated_at
should updated_at
template
<div id="test123"></div> <script id="reservationpreviewtpl" type="text/template"> <h1>i template</h1> <p><% updated_at %></p> </script>
Comments
Post a Comment