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'));
CommentFileSizeAuthor
#2 ctools-attachbehaviors-1851108-2.patch494 bytesmoonray
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

un1kum’s picture

Issue summary: View changes

Thx 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.

moonray’s picture

Here's a patch.

moonray’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Active » Needs review

And change status to trigger tests...

cyb_tachyon’s picture

Status: Needs review » Reviewed & tested by the community

#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.

  • japerry committed 9cd1ab4 on 7.x-1.x authored by moonray
    Issue #1851108 by moonray: modal.js -- Drupal.CTools.Modal.modal_display...

japerry credited japerry.

japerry’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #2828925: Plan for CTools 7.x-1.13 release

Looks right to me, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.