Reputation: 73
I've been trying to use this jquery star rating plugin: http://www.fyneworks.com/jquery/star-rating/#tab-Overview. I'm trying to get the value of the star once it's clicked but I've been having no luck. I wasn't sure where to include the following callback they suggest:
$('.auto-submit-star').rating({
callback: function(value, link){
alert(value);
}
});
I've tried sticking it around in the code but I get no alert when I click a star. Thanks!!
Upvotes: 4
Views: 3232
Reputation: 1425
https://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=21 refer to this: You must use a selector other than ".star"
Upvotes: 1
Reputation: 895
Although it's very Old POST but my experience may help someone. I too had the same issue. but able to solve it after generating the code through Ajax, and then at Success callback i invoked the rating plugin. It worked for me. I think it does not detect the class which is created on the DOM.
Upvotes: 0
Reputation: 61
$(function(){
$('input[type=radio].star').rating();
});
Remove the above lines from the jquery.rating.js, and you are all set. I suppose I don't need to explain why as it's intuitive =)
Upvotes: 5
Reputation: 31
You need to change the class on the radio buttons from star
to auto-submit-star
, don't just add auto-submit-star
to the existing class of star on the radio buttons. For example mine looks like this:
<input name="star1" type="radio" class="auto-submit-star" value="1"/>
Upvotes: 3
Reputation: 220136
Did you give your radio buttons the class name of auto-submit-star
?
<input type="radio" name="whatever" class="auto-submit-star" />
$('.auto-submit-star')
selects all radio buttons with a class of auto-submit-star
, and then sets up the rating
plugin.
On the other hand, it seems that you might be doing it before DOM ready
. In case you don't know what that is:
jQuery(document).ready(function() {
$('.auto-submit-star').rating({
callback: function(value, link){
alert(value);
}
});
});
Upvotes: 1
Reputation: 41670
Open your browser's developer tools and look in the console log; are there any warnings or error messages? If so, something's wrong in your code. Otherwise, Jospeh's answer is likely correct and your selector ($('.auto-submit-star')
) isn't selecting anything.
Upvotes: 0