3

We are launching a Magento 2.1.3 site, and finding that the site will sometimes load all of its Javascript components and dependencies properly, but sometimes fails to load, in which case a slider is not displayed and the console log shows error messages such as "Uncaught TypeError: $(...).swMegamenu is not a function".

How would we go about troubleshooting and resolving the source of these issues?

7
  • hope fully their might be a JQuery conflict.Try to short out the conflict.
    – Mujahidh
    Commented Jan 13, 2017 at 3:57
  • Please post your js code. Commented Jan 13, 2017 at 5:12
  • The relevant code causing the error I included is: <script type="text/javascript"> require([ 'jquery', 'Smartwave_Megamenu/js/sw_megamenu' ], function ($) { $(".sw-megamenu").swMegamenu(); }); </script> Commented Jan 13, 2017 at 14:05
  • We're observing today that the site will load the components on a normal reload, but not on a hard reload. Commented Jan 13, 2017 at 14:11
  • Also, the problems seem to only occur in Magento production mode, not developer mode. Commented Jan 13, 2017 at 15:17

1 Answer 1

0

Hope fully their might be a JQuery conflict.Try to short out the

You can assign a variable.You should add the below line of code where swMegamenu located in.

var jq = jQuery.noConflict();

and use the variable jq instead of $ like jq(...).swMegamenu

Hope fully this might help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.