i am using jquery star rating plugin. I have a very problem: i ask for 5 stars - the html page would display 10 stars (apparently they repeat themselves)
i use the following scripts:
$('#rating').raty({
readOnly: true,
// number: 5, 开发者_开发知识库
start: 0
});
and i went through the javascript, the default is also set to 5. Hence whether or not i set it to five it will automatically be five. But, on the html page: the number of stars are 10 to my surprise.
image from my fire bug: in this case, i ask for 4 stars, turnout to have 8 stars.
is this bug from the plugin itself or has to do with my codes?
You cant repeated IDs, it is a XHTML rule.
If you want bind more than one Raty element, you should to do the bind by class like that:
$('.raty').raty();
You can see more examples here: http://wbotelhos.com/raty
Use different names for id :
rating1-1 rating1-2 rating1-3 etc
rating2-1 rating2-2 rating2-3 etc
Example
EDIT :
You use twice or more Raty in your page ? If so, you should do it like this:
<div id="rating1"></div>
$('#rating1').Raty(etc.
<div id="rating2"></div>
$('#rating2').Raty(etc.
Well, not having access to all of your HTML & "codes", I would presume it is a fault with the plugin. However, for something like this you could easily create your own plugin.
I just encountered this issue in my application.
I used below code and it was resolved.
if($('.star').find('input[name="score"]').length < 1) {
$(".star").raty();
}
But, The odd thing was it was occurring only in tablet and mobile devices. I tried checking if it is being called twice but it was not in the code atleast.
As a workaround I added the above code.
精彩评论