In the file js/services.admin.js, the Drupal behaviors could be run multiple times, but the code doesn't handle this properly since it doesn't have .once() after the selectors. When the behaviors run multiple times, what you get is a very large number of checkboxes, because $(this).append(groupCheckbox); is called repeatedly. The extra checkboxes also break saving of the form.
To quote from an answer on Stack Overflow:
Drupal.behaviors is not simply a replacement for jQuery.ready since the latter only runs once (when DOM is ready for manipulation): behaviors can be fired multiple times during page execution and can be run whenever new DOM elements are inserted into the document.
Adding .once() will ensure that when an element has been processed, it won't be processed again.
In addition, I also noticed that the variable timeout doesn't seem to be used, but I'm not really sure what it was for so I left it.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | services-js-missing-once-3052316-9.patch | 1.49 KB | tyler.frankenstein |
| #7 | checkboxes.png | 19.98 KB | solideogloria |
Comments
Comment #2
solideogloria commentedComment #3
solideogloria commentedComment #4
solideogloria commentedComment #6
solideogloria commentedOnly failed testing because the D7 branch itself failed 15 tests.
Comment #7
solideogloria commentedI confirmed that removing the patch I created still affects the checkboxes in 7.x-3.25.
Comment #8
solideogloria commentedThis is quite easy to test. All you have to do is call
Drupal.attachBehaviors(someNode)on the resources page. So a custom module that attaches a behavior applying to the page, then calling attachBehaviors will do it.See this link for Drupal documentation on jQuery $.once().
Comment #9
tyler.frankenstein commentedYou're right, thank you for the patch!
Thank you for pointing this out, I've removed the unused variable.
I've included the updated patch for reference.
Comment #11
tyler.frankenstein commented