(This is an offshoot of #222953: Fivestar doesn't work properly with Thickbox in Firefox, to allow Fivestar to work in a Thickbox.)
1. The JS portion does $('...').rating() to kick in the pyrotechnics. However, no protection against multiple calls is in place. A 'guard class', e.g. 'jsrating-processed', should be used --as is done in any other place in Drupal.
2. Currently, the JS code uses "$(document).ready(...)". It should instead use "Drupal.behaviors".
(Preferably, we should use some simple logic to make the code run on D5 as well; We don't want to maintain two versions of 'jquery.rating.js'.)
Comments
Comment #1
mooffie CreditAttribution: mooffie commentedI forgot to explain what these two points (actually, only the first point) has to do with Thickbox:
When Thickbox loads a page, in a 'box', it does this via Ajax. It eval()s the scripts of this new boxed page, and --that's important!-- it does this in the context of the 'main' page. So if the 'main' page contained some Fivestar widgets already, $(...).rating() would be re-applied on them, and the result is that the widgets are showed twice.
Comment #2
quicksketchYeah agreed on all points. Right now the 6.x version is identical to 5.x javascript. Using behaviors is a good move though to make AHAH additions of Fivestar an easy task.
Comment #3
quicksketchFivestar wasn't properly using behaviors, even in 1.13. I've switched it to using behaviors in the Drupal 6 version, and added the guard class like you suggest in both the Drupal 5 and 6 versions.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.