By Stefan Suck on Monday, 19 February 2018
Posted in MetaMan
Replies 5
Likes 0
Views 1.5K
Votes 0
Greetings!

Our website uses the bootstrap framework and jQuery. After activating MetaMan however, we noticed that the mobile menu (hamburger symbol) doesn't work properly. It reacts only on the second mouseclick and behaves irregularily afterwards when using the jQuery's toggle function.
We managed to pin down the cause of this in the onAfterInitialise-Function in the PlgSystemMetaman-Class. On line 62, following code is executed:


// Ensure that jQuery is enabled on the site
if (MM::requirejQuery()) {
$this->doc->addScript($this->baseurl . '/plugins/system/metaman/assets/scripts/jquery-3.1.0.min.js');
} else {
JHtml::_('bootstrap.framework');
}


As we understand, this checks if a current version of jQuery is used. If the jQuery version is 1 or 2 (checked in requirejQuery), it adds the jQuery-3-Script. Otherwise, it includes the bootstrap framework.
This causes a conflict, as bootstrap is already used on our side, which seems to cause the toggle-function of jQuery to be bound twice to the menu button, which leads to the strange behavior.
This can be simply tested by commenting out the
JHtml::_('bootstrap.framework');
line. In doing so, the mobile menu behaves normally.

The only solution we found was to either edit the plugin (which we want to avoid), make an override for our own jQuery-library (which may cause unwanted side-effects) or use a custom toggle-script (which seems to be unneeded effort).

Do you have any better idea how to fix this?
Hey Stefan,

I think the problem here is related to your mobile menu and the way it relies on bootstrap. The primary reason that you are hitting this conflict is because your template isn't using the standard bootstrap that is included in Joomla.

There is no right or wrong about this but if all templates uses the standards in Joomla, everyone would be at a safer end. Since Metaman does not require bootstrap from Joomla (only jquery), we'll see if we can modify the codes so that it only renders jQuery from Joomla rather than the entire package (not sure if it is possible with Joomla but we'll check)

Temporarily, you should comment out the codes that renders jquery and force Metaman to use it's own jquery
·
Monday, 19 February 2018 19:14
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you for the fast reply.
We will use the temporary fix for now!
·
Monday, 19 February 2018 20:06
·
0 Likes
·
0 Votes
·
0 Comments
·
You are most welcome Stefan
·
Tuesday, 20 February 2018 00:15
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Stefan,

Could you replace the codes below,

[gist]
JHtml::_('bootstrap.framework');
[/gist]

With,

[gist]
JHtml::_('jquery.framework');
[/gist]
·
Tuesday, 20 February 2018 13:55
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post