I'm customizing a few things within the Opigno LMS distribution and noticed an issue (there might be more spots) with using AJAX on the page. In Drupal, when an ajax request is called on the page, it automatically calls "Drupal.attachBehaviors()" oncomplete, which will re-attach all javascript in the "behaviors" object back to the entire page.

Drupal.behaviors.platon (platon.js)

Line 220:
$menuTrigger.click(function() {
change to
$menuTrigger.once().click(function() {

That needs to make use of once() to prevent adding multiple click handlers to the menu toggle.
https://www.drupal.org/docs/7/api/javascript-api/managing-javascript-in-...

For a test, install the flag module and add an ajax flag to w/e node page you want. Everytime you hit that link, that ajax request is fired, it adds another open/close click to the menu toggle button. So if you press the flag link 5x times, it will open and close 5x.

This is the first spot I have noticed, there might be more spots in there as the javascript needs some efficiency updates. Anyway, I didn't create a patch as there may be more areas. Let me know if I can help further and if I find more spots as I build this out, I will post up.

CommentFileSizeAuthor
#2 menu-toggle-ajax-issues-2849553-2.patch724 bytesiLLin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iLLin created an issue. See original summary.

iLLin’s picture

Attached patch that addresses the login dropdown, and the sliding in/out menu on left.

iLLin’s picture

Status: Active » Needs review

  • Amermod committed c58d098 on 7.x-3.x authored by iLLin
    Issue #2849553 by iLLin: Menu Toggle - AJAX issues with Drupal....
amermod’s picture

Status: Needs review » Patch (to be ported)

Hi iLLin,

Thanks a lot for your help and for the issue found and fix.
I've added your fix to the next commit.

Again, thank you !
Best regards,
Allan

amermod’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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