Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Since it's the callback for an AJAX command, Drupal.CTools.Modal.modal_display() should pass the 'context' argument to Drupal.attachBehaviors(). (See function documentation in drupal.js.) This allows limiting all attach functions to apply only to the new markup placed in the modal, when it is opened.
Specifically I'd change modal.js line 286 to:
Drupal.attachBehaviors($('#modalContent'));
Comment | File | Size | Author |
---|---|---|---|
#2 | ctools-attachbehaviors-1851108-2.patch | 494 bytes | moonray |
Comments
Comment #1
un1kum CreditAttribution: un1kum as a volunteer commentedThx for your proposal! Helped me.
I use modal forms, for webforms, and until I used your code I had the error below:
"$(...).once is not a function"
However, in my file, that was not the line 286, but 302.
Comment #2
moonray CreditAttribution: moonray at Chapter Three for Stanford University commentedHere's a patch.
Comment #3
moonray CreditAttribution: moonray at Chapter Three for Stanford University commentedAnd change status to trigger tests...
Comment #4
cyb_tachyon CreditAttribution: cyb_tachyon as a volunteer and at Red Hat commented#2 Confirming fixes multiple issues with attaching behaviors to ctools modals, including the "$(..).once is not a function" JS error.
Code looks good, this is a one line change.
Tests are passing, setting to RTBC.
Comment #7
japerryLooks right to me, committed.