Rails 3 upgrade: using Prototype + jQuery. Replace instances of '$' in rails.js with 'jQuery?' -
we upgraded rails 3.
we replaced default "rails.js" file jquery version.
because our legacy app uses prototype , '$' reference, assume need replace '$' references 'jquery' in jquery version of "rails.js."
however, have not done so, , seems work fine. moreover, can't find documentation suggesting need to.
is necessary? it's not clear how "rails.js" automatically knows use jquery instead of prototype when comes '$' references.
usually way done (as mentioned in comment) this:
(function($){ $(some_stuff_that_uses_$); })(jquery);
this anonymous self-executing function. you're taking anonymous function function($){}
, running passing parameter jquery
it. quick way make sure jquery code stays separate other frameworks might try use $
.
however, think rails.js this...so it's possible won't have anything.
it's practice have of jquery files regardless of whether or not have multiple frameworks.
Comments
Post a Comment