JQuery rating rating plugin and unrate rating button
Using this plugin: http://www.fyneworks.com/jquery/star-rating/#tab-Testing
I have a simple callback function that retrieves an id from 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 great, but if the user clicks the cancel button, then he cannot read his ID.
In 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? It will be undefined. I can install the class and use $ ('. Myclass'). Attr ('id'), but I will have multiple ratings on the same page, so I need something similar to "this". Or is it possible for the cancel button to select the id of the corresponding radio buttons?
source to share
Ok Roger - I found this because I faced the same EXACT issue. This is how I solved it so far. I hope the plugin will be fixed in the future. I believe you don't need the problem solved at this point, but it might help other people. Obviously, it relies on the structure of the DOM elements, hence not a very elegant solution.
//RYAN OBEROI: A big hack, since the cancel callback does not have the appropriate information
name = $(this).parent().next().attr('name')
// click callback, as requested here: http://plugins.jquery.com/node/1655
if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0], name]);// callback event
source to share