Jquery star rating plugin and cancel rating button
- by Roger
Using this plugin: http://www.fyneworks.com/jquery/star-rating/#tab-Testing
I have a simple callback function that picks up the id from the radio buttons:
<input type="radio" class="auto-submit-star {split:2}" id="myid" value="1" />
$('.auto-submit-star').rating({
callback: function(value, link){
alert($(this).attr('id'));
}
});
This works fine, but if the user clicks on the cancel button, then it can't read the id of it.
In the js, I think the cancel button is added dynamically with:
control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>')
If I add an id to it like this:
control.cancel = $('<div class="rating-cancel"><a id="someid" title="' + control.cancel + '">' + control.cancelValue + '</a></div>')
How could I read the id? This would be undefined. I can set a class and use $('.myclass').attr('id') but I will have multiple ratings on one page so I'll need something similar to "this". Or is it possible for the cancel button to pick up the id of the corresponding radio buttons?