I'm having trouble with the module, when using with AJAX enabled.
The request to load the feedback form works fine, but all the behaviors on the page are invoked when the AJAX returns and the context is equal to the document. Normally, the context should be the element that is going to be replaced by the result of the AJAX call.

How could I specify the context correctly for these AJAX requests?
Any help is much appreciated!

Comments

reszli created an issue. See original summary.

reszli’s picture

It seems to be caused by the following line in feedback-collect.js:

// For some reason behaviors don't bind on added ajax content, init it after everything was processed.
Drupal.attachBehaviors();

I would replace it by something like, to prevent another attach with document as context (it left empty it uses document):

// For some reason behaviors don't bind on added ajax content, init it after everything was processed.
Drupal.attachBehaviors($wrapper);

it should not break the 3 attach function of the module itself, since the context is not used in any of them:

Drupal.behaviors.feedbackCollectSetMaxHeights
Drupal.behaviors.feedbackCollectBrowserInfo
Drupal.behaviors.feedbackCollectSaveFormOnLeave
jelenakrmar’s picture

Hi, thanks for pointing out to the problem and suggesting a possible solution. I'll look into it and try to make improvements in the next couple of days. Can you please give me more detail about the specific problem and how to recreate it? Because I am using this module in a project with a lot of AJAX and Javascript and haven't noticed any problems.

Thanks,
Jelena

monstrfolk’s picture

@reszli....did you test your suggestion? Does it work? I am also having a problem with the Javascript. Modal window div is not removed from the HTML document on small width devices. Modal div is attached to the root document.

See... https://www.drupal.org/node/2845654

  • ntucakovic committed 190caea on 7.x-1.x
    Issue #2833399: Context after AJAX request - Pass context used in module...
ntucakovic’s picture

Status: Active » Needs review

Thank you for waiting this long for the patch. If you could test it out now @reszli ?

Should be fixed by narrowing down where to re-attach behaviors.

monstrfolk’s picture

which branch has this commit?

jelenakrmar’s picture

7.x-1.x

monstrfolk’s picture

A new release needs to be created with this fix.

jelenakrmar’s picture

done :)
7.x-1.4

ntucakovic’s picture

Status: Needs review » Fixed

As mentioned, fix is included in latest 7.x-1.4 release.

monstrfolk’s picture

i found it...thanks.

Status: Fixed » Closed (fixed)

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