3

I've added jquery 1.8.2 to both my page.xml file and the corresponding directory.. however i am still getting multiple Uncaught ReferenceError: jQuery is not defined errors.

Jquery no conflict has been added.

In the page.xml file the script src is

<action method="addJs"><script>jquery-1.8.2.min.js</script></action>

and it is the first script.

    <block type="page/html_head" name="head" as="head">

<action method="addJs"><script>jquery-1.8.2.min.js</script></action>

        <action method="addJs"><script>prototype/prototype.js</script></action>

        <action method="addJs"><script>lib/ccard.js</script></action>

        <action method="addJs"><script>prototype/validation.js</script></action>

ect.

  • Looks like you're loading in Jquery twice (ajaxcart is loading it too) - one could be un-registering the other, despite them being the same versions. – Douglas Radburn Jun 18 '14 at 18:47
  • @DouglasRadburn i've disable and reenabled it with no luck – xoxoxo Jun 18 '14 at 18:48
  • Have you tried calling noConflict as soon as jQuery is loaded? The call is further down the page (and after a jQuery block of code!) – Douglas Radburn Jun 18 '14 at 18:54
4

Create a new .js file for eg. no-conflict.js and add the following content on it:

var $j = jQuery.noConflict();

And include your no-conflict.js just after your

<action method="addJs"><script>jquery-1.8.2.min.js</script></action> like this:

<action method="addJs"><script>no-conflict.js</script></action>

Then write your jQuery like this:

$j(document).ready(function(){
// write your code here
});

P.S. for more information on solving jquery conflict refer http://magento-online-tutorials.blogspot.in/2015/10/how-to-solve-jquery-and-prototype.html

  • I have tried this. If i add $j(document).ready(function(){ // write your code here }); then i get $j is undefined – xoxoxo Jun 19 '14 at 13:05
  • just check in the page view source no-conflict.js is loading after the jquerylibeary – Pradeep Sanku Jun 19 '14 at 13:07
  • it is @pradeepsanku. The file containing var $j = jQuery.noConflict(); is next after jquery. The nocoflict.js gets Uncaught ReferenceError: jQuery is not defined as well – xoxoxo Jun 19 '14 at 13:09
  • which magento version you are using ? – Pradeep Sanku Jun 19 '14 at 13:13
  • Magento ver. 1.8.1.0 @pradeepsanku – xoxoxo Jun 19 '14 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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