Using jQuery with Magento Including Protype, Scriptaculous etc...

Posted by Damodar Bashyal on May 03, 2009

 

How to use jQuery with Magento?

Download jQuery from jQuery site

Add this line to the bottom of jQuery.js

jQuery.noConflict();

Copy the file to the js/jquery folder|directory

In page.xml, add it to the list of js files as:

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

or,

<action method="addItem"><type>js</type><name>jquery.js</name><params/></action>
How to use jQuery with magento now?

The below procedure is one way.

jQuery(document).ready(function($){
// Use jQuery with $(...)
$('div').show();
});
// Use Prototype with $(...)
$('id').hide();

note: $ sign inside function($).

And another procedure is,

jQuery(document).ready(function(){
// Use Prototype with $(...)
$('id').hide();
// Use jQuery with jQuery(...)
jQuery('div').show();
});

There are few more procedures available at jQuery site. But this much information is good to go with using jQuery with magento which uses prototype, scriptaculous etc...

King Rosales posted on - Saturday 5th of June 2010 02:13:49 PM

Hi Bashyal, thanks for this post. does this work with the lastest version of magento 1.4? or will it work if the version of jquery is something other than version 1.2.6? ie. version 1.4.2 (latest)

Damodar Bashyal posted on - Saturday 5th of June 2010 02:15:50 PM

So far i know it works with all versions.
 
not published on website


QR Code: Using jQuery with Magento Including Protype, Scriptaculous etc...