pivotal developer
pivotal developer

Reputation: 503

jquery star rating - raty plugin bug

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.

enter image description here

is this bug from the plugin itself or has to do with my codes?

Upvotes: 1

Views: 3720

Answers (4)

Avinash Gosavi
Avinash Gosavi

Reputation: 1

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.

Upvotes: 0

Washington Botelho
Washington Botelho

Reputation: 732

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

Upvotes: 1

GG.
GG.

Reputation: 21854

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.

Upvotes: 0

mattsven
mattsven

Reputation: 23293

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.

Upvotes: 0

Related Questions