我使用一個jQuery rating plugin,我使用這個在這樣一個div:插件不使用Ajax加載內容的工作
HTML:
<div id="highlighted" class="span6">
<div class="row">
<div id="high-desc" class="span4">
<span class="movie-title fat"><a class="strong" href="movies.jsp?id=5">Watchmen</a> (2009)</span><br />
<div id="rating"></div>
</div>
</div>
的Jquery:
$("#rating").rateit({
max: 10,
min: 0,
step: 1
});
它效果很好。但是,當我用其他內容(如下)替換div#highlighted
的內容時,插件不起作用。
$('// some link').on("click", function(){
var Id = // some id
title="reco_product_stream.jsp?type=high&id="+Id;
('#highlighted').load(title);
});
我甚至嘗試重裝就這樣每次Ajax調用插件:
$('// some link').on("click", function(){
var Id = // some id
title="reco_product_stream.jsp?type=high&id="+Id;
('#highlighted').load(title);
$("#rating").rateit({max: 10, min: 0, step:1});
});
但它不工作。
這只是一個建議,但下面的官方例子可以幫助你:http://www.radioactivethinking.com/rateit/example/example.htm#ex_11 (例如#11 ) –