After invoke command ctools_modal_form_wrapper() on ajax response, Drupal attaches js behaviors for the whole document, instead of modal dialog. This causes duplicetes of ajax events for all selectors that uses context variable.


$('.my-button', context).click(function() {
  console.log('I am invoked');

When page is loaded, click on this button will log only one message. But after modal dialog was invoked, the same click event will write in console two debug messages. After one more ajax response with modal dialog we will see three messages in console, etc.

Proposed solution

Add correct context for Drupal.attachBehaviors after modal context was invoked. Patch is attached.

#1 ctools-modal-dialog-invokes-drupal-attachBehaviors-with-wrong-params-2001370-1.patch522 bytesSpleshka
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es). View
ctools-modal-dialog-invokes-drupal-attachBehaviors-with-wrong-params.patch519 bytesSpleshka
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es). View


Spleshka’s picture

522 bytes
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es). View

Removed extra spaces.

duozersk’s picture

Status: Needs review » Reviewed & tested by the community

Yup, looks pretty clear and straight forward fix to me.

Spleshka’s picture

Any progress here? Patch is almost obvious.

Spleshka’s picture

Still no progress? :(

podarok’s picture

Assigned: Unassigned » merlinofchaos

#1 looks good for me
let`s make it pushed

japerry’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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