The way rate.js calls attachBehaviors causes the get request to get attached to unwanted elements. For example, if you use the smileys module every time you rate something it duplicates the "more" link..

Line 30 of rate.js:
Drupal.attachBehaviors(p.get(0));

Should be:
Drupal.behaviors.rate(p.get(0));

Otherwise things like this happen:
http://i861.photobucket.com/albums/ab174/gutretch/Picture5-1.png

Comments

bertboerland’s picture

thanks for reporting, we wil look in to this

mauritsl’s picture

Title: rate.js attachBehaviors() wrong DOM selection » calling attachBehaviors() twice breaks smileys module
Project: Rate » Smileys

This is not a bug in Rate, but in the smileys module.

Your suggestion indeed solves the problem at first. But other behaviors which were added to the widget will stop working anymore. This is the case for the javascript on the fivestar widget (will be added in rate 1.2).

The smileys JS has to know if it already processed items by setting a processed class, making it save to call attachBehaviors multiple times.

Rate does this with the following code:

Drupal.behaviors.rate = function(context) {
  $('.rate-widget:not(.rate-processed)', context).addClass('rate-processed').each(function () {
    //
  }
}

Rate is not the only module which calls Drupal.attachBehaviors! Various others are doing:
http://drupal.org/node/983738
http://groups.drupal.org/node/20318

This seems to be the usual way, so it really has to be fixed in the smileys module and not in rate.