简体   繁体   English

在Mustache.js模板中使用时Rateit插件不起作用

[英]Rateit plugin not working when used in Mustache.js template

I am using RateIt Pugin in my Mustache.js template but it is not showing up any thing. 我在Mustache.js模板中使用RateIt Pugin ,但未显示任何内容。

When i am using it RateIt directly in HTML its working fine 当我在HTML中直接使用RateIt时,它的工作正常

below is my mustache template 下面是我的胡子模板

<script id="category_list" type="text/template">
  <li> Rate {{movie_name}}:
      <div  class="rateit">
      </div>
  </li> 
</script>

Below is my JS code to get the template and add it to main page 下面是我的JS代码以获取模板并将其添加到主页

 var data={
            movie_name:'some movie'
        };
$.get('js/temp.html', function(template, textStatus, jqXhr) {
    var menu_list=Mustache.render($(template).filter('#category_list').html(), data);
    $('#movie_details_list').empty().append(menu_list);
    $.mobile.changePage( '#movie_details_page', { transition: "slide", changeHash: false });
});

this is my HTML 这是我的HTML

<div data-role="page" id="home">
    <div data-role="content">
      <ul data-role="listview" id="movie_details_list" >
      </ul>
    </div>
  </div>

You have to fire rateit() after loading the template. 您必须在加载模板后触发rateit() I didn't understood your result/template logic and did some adjustments: 我不了解您的result/template逻辑,并做了一些调整:

var template = $('#category_list').html();
Mustache.parse(template);
var data={
   movie_name:'Stack in the Galaxy'
};
$.get('temp.html', function( result, textStatus, jqXhr ) {
    var rendered = Mustache.render( template, data );
    $('#target').html( result );
    $('#movie_details_list').append( rendered );
    $('div.rateit, span.rateit').rateit(); // <-- start up RateIt
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM