Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow score to be set back to 0 #44

Closed
dannyroa opened this issue Jul 23, 2012 · 4 comments
Closed

Allow score to be set back to 0 #44

dannyroa opened this issue Jul 23, 2012 · 4 comments

Comments

@dannyroa
Copy link

After I initialized it the element with raty, I should be able to reset the value to 0.

I tried:

$("#rating_selector").raty('set', {'score' : 0});

$("#rating_selector").raty('score', 0);

Both creates new rating.

@wbotelhos
Copy link
Owner

Hi dannyroa,

Semantically there is no way to vote as zero.
The minimum is half. A no rated star has the default state of an input element: no value.

But if you want set zero, change the lines:
https://github.com/wbotelhos/raty/blob/master/js/jquery.raty.js#L64
https://github.com/wbotelhos/raty/blob/master/js/jquery.raty.js#L398

But remember, you cant click on star number zero and the cancel button take off the value.

@dannyroa
Copy link
Author

My rating selector is in a form. When I reset the form, it should reset the rating too.

What is the best way to do this?

Thanks.

@wbotelhos
Copy link
Owner

You can manually clear the value attribute:

$('.rating input').removeAttr('value');

Or call the cancel function:

$('.rating').raty('cancel');

@dannyroa
Copy link
Author

I was trying to do 'cancel' earlier but it wasn't working. Turned out I had an old version of the plugin.

Sorry about that.

Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants