Scenario:
Page displays two entities, each with a yes/no rate widget. A "Load more" button is clicked, which triggers an AJAX event that loads two more entities with their own rate widgets. Voting in any of the four widgets now causes an error (image1).
Cause:
The module expects Drupal.settings.rate.basePath to be a string, but due to the cumulative nature of drupal_add_js(), it becomes an array after the AJAX call. (image2)
Errors:
Some errors that I have seen result from this are:
TypeError: Drupal.settings.rate.basePath.match is not a function
Uncaught TypeError: undefined is not a function
Uncaught TypeError: Object [object Array] has no method 'match'
Comments
Comment #0.0
yuriy.babenko commentedfixed typo
Comment #1
yuriy.babenko commentedAfter reading through https://drupal.org/node/208611, https://drupal.org/node/1875632, and https://drupal.org/node/1911578, I'm thinking this is a Drupal core issue, not Rate specifically.
I've attached a workaround patch. It's ugly, but it works.
Comment #1.0
yuriy.babenko commentedfixed typo
Comment #2
rooby commentedI have had issues with this module and the https://www.drupal.org/project/views_load_more ajax views paging and this patch resolves the issue for me
Comment #3
rooby commentedComment #4
rooby commentedComment #5
rooby commentedHere is an updated patch with no code changes.
Just rerolled to apply cleanly to the latest dev version of the module with patch -p1.
Comment #6
Anonymous (not verified) commentedThe patch fixes my issue with views load more, also tested with pager options with ajax, works great. Thanks @rooby and @yuriy
Comment #7
jrabeemer commentedThis patch works. But after a few rate button clicks after an AJAX refresh, I get multiple progress icons that stack exponentially per rate button click. Sorry but I can't tell if this is within the scope of this bug or not.
Comment #8
Fidelix commentedIt worked flawlessly for me, and I'm doing a bunch of complex ajax stuff with the comments.
Comment #9
quotesbro commented#1 worked for me too, thanks Yuriy.
Comment #10
ivnishDrupal 7 is EOL. Issue will be closed, but patches are still here