Wednesday, March 31, 2010

jQuery with rails

Hi all,

I have used the jquery js prototype recently, it has lots of more usage than our prototype.js. Easy to code using jQuery.js.

But in my rails application i have used both prototype.js & jquery.js. In this situation the $ gets conflict. To avoid conflict, use the line of code

First include prototype.js, then add jQuery.js after that you must add this line to avoid ($)conflict


Once you done this, you can enjoy the usage of both prototype.js & jQuery.js.

i.e., both $ and $j is available to access.

$('id_of_dom_elemnt') => returns (prototype)object of the html element
$j('#id_of_dom_element') => return (jquery)object of the html element

In jQuery, we have to add '#' symbol with id of dom element to find the element.

Enjoy coding with jQuery...

thanks,