在这里,我有代码使用http://wbotelhos.com/raty,http://wbotelhos.com/raty/lib/jquery.raty.min.js将数字(评级)转换为星星
我创建了一个 jsfiddle:http: //jsfiddle.net/3SXKe/4/
// mocking your supposed "place" variable
var place = { name: "James Cook Hotel Grand Chancellor", rating: "3.6",
photos: [{ getUrl: function () { return "https://lh6.googleusercontent.com/-T0_fJX5zza0/UdSnOaucZvI/AAAAAAAAAFc/gQhK3IbHJfY/w50-h50-s0/Small%2BLogo.png" } }]
}
var photo = place.photos[0].getUrl({
'maxWidth': 50,
'maxHeight': 50
});
var elemenatDiv = $('<div>').addClass('elemenat');
var draggableDiv = $('<div>').addClass('draggable');
var logo = $('<img>').css({'margin-left': '3px', 'margin-top': '5px'})
.attr('src', photo).attr('width', 46).attr('height', 42)
var sideClick = $("<a>").addClass('side_click').attr('href', '#')
.text(place.name + place.rating);
var elementnameDiv = $('<div>').addClass('elementname');
var star = $('#star').raty({ score: place.rating });
elemenatDiv.append(draggableDiv.append(logo));
elemenatDiv.append(elementnameDiv.append(sideClick).append(star));
$("#side_bar").append(elemenatDiv);
$(sideClick).on("click", function () {
markers[i].modalWindow_.getDetails(markers[i].place_);
});
我首先使用: var star = $('#star').raty({ score: place.rating });
然后附加 elemenatDiv.append(elementnameDiv.append(sideClick).append(star));
但是渲染html代码时不会显示星级?
我尝试了不同的解决方案,但我不知道错误在哪里?