So, does anyone use PrototypeJS with jQuery?
So, does anyone use PrototypeJS with jQuery?
I’ve used prototype with jquery before. Now, I only use jquery since it’s supported out of the box
by rails3 (with ajax helpers working using the jquery-rails gem). I remember that you just have to
add a single line to make prototype working with jquery.
var $j = jQuery.noConflict();
then remember to use $j instead of $ when you want to use jquery functions.
It's generally not a good idea to use two large libraries like this in the same page. Not only do they conflict (unless you use the jQuery.noConflict() patch to rewrite any uses of the $ function defined in Prototype) but they each do more or less the same thing, so it's a waste to force a download of both on your users.
It's been my experience that anything you want to do in jQuery you can do in Prototype, and vice-versa.
Walter
CoffeScript is standard from Rails 3.1 so it will be the best practice for sure. http://jashkenas.github.com/coffee-script/ Give it a try, bests: gezope
Coffeescript has nothing to do with Javascript libraries like jQuery or Prototype. It’s a precompiler for Javascript, i.e. it converts Coffeescript code to Javascript.
Yes, we use Prototype and jQuery together. You just need to put jQuery into compatibility mode and then use jQuery(“blahblah”) for jQuery code and the usual $ for Prototype. Be on the lookout for badly written jQuery plugins though (the ones that don’t scope their code).