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.
I'm using the following JS in a custom module that implements a toggle menu for mobile browsers:
(function ($) {
Drupal.behaviors.mobilemenu = {
attach: function (context, settings) {
$("#toggle").click(function() {
$("#block-menu-block-5").slideToggle('fast');
return false;
});
}
};
})(jQuery);
On any page with an openlayers map, a click to the #toggle link opens and closes the intended element (rather than staying open). Seeking any advice as to why this may be the case.
Thanks in advance.
Comments
Comment #1
PolI don't think that this is related to the OL Drupal module, but the OL library itself.
Can you debug with firebug ?
Comment #2
IshaDakota CreditAttribution: IshaDakota commentedI think you are right about the problem being in the library. I am going to try debugging... I'm not terribly proficient in javascript.
I can see already, though that the root of the problem is the the script is loaded twice and then fires twice on the click event.
Comment #3
cdykstra CreditAttribution: cdykstra commentedI'm experiencing the same issue with slideToggle and openlayers. Was a resolution ever found for this?
Thanks!
Comment #4
jienckebd CreditAttribution: jienckebd commentedI'm having the same problem as well.
Comment #5
IshaDakota CreditAttribution: IshaDakota commentedShould have documented this when I got it to work. I used unbind() as such,
Not sure this is the right way to do it, but it did work for me.
Comment #6
cdykstra CreditAttribution: cdykstra commentedIshaDakota, you rock! This fixed the issue for me, thanks for coming back around and sharing your fix.
Comment #7
letrotteur CreditAttribution: letrotteur commentedThat did the trick for me too. Thank you!
Comment #8
mansspams CreditAttribution: mansspams commentedMaybe it did the trick, but it did not fix OpenLayers behaviours. Your jQuery will fire as many times as there are maps on page plus one. Because...
I'm looking into issue. Let's hope there is a way ;)
Comment #9
slcp CreditAttribution: slcp commentedThis appears to be being addressed in 7.x-3.x in this issue #1332836: Behavior re-architecting, use map level event system.
Comment #10
PolThis message is part of the issue cleanup initiative.
Openlayers 2.x has been deprecated since the release of Openlayers 3.x the 31 December 2015.
If you want to stay on 2.x, you should try with the latest version of the 2.x release.
However, I strongly encourage you to move on version 3.
Version 3 is much more stable than version 2. It does not yet contain all the features but the main ones are there.
I'll close this thread, feel free to reopen it if needed.
Thanks for your understanding.