eddysilvamendes / jquery-star-rating-plugin

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

Callback never called due to interference by "default implementation" at bottom of rating.js #65

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  Attach a callback to the radio inputs in a document ready event

    $(document).ready(function(){
      $('input').rating({
        callback: function(){ alert(1); }
      });
    });

2.  Click a star to rate it, note that the alert(1) is never reached

What is the expected output? What do you see instead?

  Expected output is an alert() fired via the callback.  Instead, nothing happens.

What version of the plugin/jQuery are you using?
PLUGIN VERSION: v3.13
JQUERY VERSION: 1.4.2

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

Please provide a link to where the problem can be observed:
URL: http://jsbin.com/ujawi3/edit

Feel free to provide any additional information below.

The above jsbin url shows the bug.  Note the "quick" fix is to remove the

  $(function(){
     $('input[type=radio].star').rating();
    });

At the bottom of the star rating plugin.  It would appear that the problem 
stems from the fact that the callback in the options is never attached because 
the if() statement ~line 66 evaluates to true (because the control was already 
created by the "default implementation" at the bottom of the rating plugin 
.js).  And it appears the callback is only assigned in the else branch of this 
evaluation.

Not that this behavior is also sometimes observed when the callback is *not* 
added in the domready event, but this behavior is variable (hence the need for 
domready in most DOM manipulating JS)

Original issue reported on code.google.com by belor...@gmail.com on 24 Aug 2010 at 8:58

GoogleCodeExporter commented 8 years ago
see http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=58#c2

Original comment by lnicole...@gmail.com on 1 Feb 2011 at 9:20

GoogleCodeExporter commented 8 years ago

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