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.

3
  • 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. Commented Jun 18, 2014 at 18:47
  • @DouglasRadburn i've disable and reenabled it with no luck Commented Jun 18, 2014 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!) Commented Jun 18, 2014 at 18:54

1 Answer 1

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

12
  • I have tried this. If i add $j(document).ready(function(){ // write your code here }); then i get $j is undefined Commented Jun 19, 2014 at 13:05
  • just check in the page view source no-conflict.js is loading after the jquerylibeary Commented Jun 19, 2014 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 Commented Jun 19, 2014 at 13:09
  • which magento version you are using ? Commented Jun 19, 2014 at 13:13
  • Magento ver. 1.8.1.0 @pradeepsanku Commented Jun 19, 2014 at 13:15

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.