eddysilvamendes / jquery-star-rating-plugin

Automatically exported from code.google.com/p/jquery-star-rating-plugin
0 stars 0 forks source link

incorrect 'a' reference when clicking on the cancel button #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Click on the cancel button of the rater

What is the expected output? What do you see instead?
The event handler is expecting two parameters:
1- The value of the selected star (or in this case cancel)
2- A reference to the link clicked

The selector fails in this case and the first link (a) of the document is
returned instead.
Below is the lines that are breaking

var input = $( control.current ? control.current.data('rating.input') : null );
if (control.callback) control.callback.apply(input[0], [input.val(), $('a',
control.current)[0]]); // callback event

What version of the plugin/jQuery are you using?
PLUGIN VERSION: 1.3.2
JQUERY VERSION: 3.12

On what browser(s) or operating system?
BROWSER(S): Firefox

Original issue reported on code.google.com by martinj...@gmail.com on 24 Sep 2009 at 7:39

GoogleCodeExporter commented 8 years ago
The problem is that the control.current is null when the user click the cancel 
button.

Here is my lame fix:

var myContext;
if (control.current == null)
    myContext = control.cancel;
else myContext = control.current;
var input = $(control.current ? control.current.data('rating.input') : null);
if (control.callback) control.callback.apply(input[0], [input.val(), $('a',
myContext)[0]]); // callback event

Original comment by martinj...@gmail.com on 24 Sep 2009 at 7:58

GoogleCodeExporter commented 8 years ago

Original comment by diego.a...@gmail.com on 23 Feb 2013 at 5:12