I cannot include Jquery in magento because after including jquery-2.2.2.min.js in magento admin side,it have conflict with prototype.js.
Adding $.noConflict();
can remove the conflict,but the jquery will not work then.This is the actual problem.
0
1
You can just include jquery using below way, in template file,
<script>
require(["jquery"],function($){
///your jquery code
});
</script>
-
-
Run php command from your magneto root, php bin/magento setup:static-content:deploy – Rakesh Jesadiya Jul 11 '17 at 6:23
-
I didn't get you. Actually when iinclude jquery in my phtml file it have conflict with prototype.js. It can avoid using your method? – amrutha Jul 11 '17 at 6:40
-
-
actually include <script src="<?php echo Mage::getBaseUrl('js') ?>hpp/jquery-2.2.2.min.js" type="text/javascript"></script> in magento admin – amrutha Jul 11 '17 at 6:51
0
Place your jquery file in
js
directoryAdd the following code to your layout .xml file in respective handle. For Ex: to reflect in all pages
This should fall under <reference name="head">
<action method="addJs">
<script>path/to/your/jquery</script>
</action>
jQuery.noConflict()
removes the conflict (not$.noConflict()
because$
still belongs to Prototype.js). Please show an example of a script that does not work then. You probably use$
in the global scope. Instead you should either usejQuery
, or wrap any jQuery code in a closure like this:(function($) { .... })(jQuery);
– Fabian Schmengler Jul 12 '17 at 9:10