Reputation: 272
I am using ajb's star rating. It works perfectly on HTML but when I try to load it through jquery html() function. font-awesome star did not show up. Any help are appreciated.
$(document).ready(function () {
var html = "<div class=' panel active-panel '>" +
"<div class='panel-heading'>" +
"<div class=' pull-right'>" +
"<div class=\"mstars starrr\" data-rating='4'>" +
"<span id=\"count\">0</span> star(s)</div>" +
"</div>" +
"<h4>Bootstrap Examples 4</h4>" +
"</div>" +
"<div class='panel-body'>" +
"<div class='list-group'> <a href='#' class='list-group-item'>Modal / Dialog</a>" +
"<a href='#' class='list-group-item'>Datetime Examples</a>" +
"<a href='#' class='list-group-item'>Data Grids</a>" +
"</div>" +
"</div>" +
"</div>";
$('div.bcard').html(html);
});
http://jsfiddle.net/zmoxq/vyrmh7eh/
Upvotes: 1
Views: 153
Reputation: 14927
That plugin initializes the star ratings on dom ready, yours is being added after dom ready, so you need to call the plugin yourself on your added HTML.
To do that, change this:
$('div.bcard').html(html);
to this:
$('div.bcard').html(html).find(".starrr").starrr();
Upvotes: 1