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

enter image description here

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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -