Anyone needing the compatibility can simply remap $ like this after loading jQuery:
var $J = jQuery; $ = _$; I think other libraries would be nice to provide such an easy way to make them compatible with jQuery and others. -- Brandon Aaron On 11/13/06, henrah <[EMAIL PROTECTED]> wrote: > > > Hi all, > > I actually posted this in bug #137 - Prototype Support Plugin, but then I > realized it might be more appropriate on the mailing list, since I'm looking > for feedback on this idea. > > > Is the main issue here making jQuery compatible with Prototype, or just > making it compatible with all other libraries (now including mootools et al) > which use '$' as a shortcut in the global namespace? > > I think it's worth pointing out that jquery.js is written well enough that > it doesn't have to map the jQuery function to $, except as a convenience to > users, and for backwards-compatibility with existing plugins. There is > (presumably) no future-compatible way to consistently merge the output of > jQuery and Prototype's '$' functions together -- and this would remain ugly > and messy, in any case. My suggestion would be providing the option to map > jQuery to a different shortcut (like $J, for example), and not override > prototype's $, if this is what the user would prefer. > > There are a number of ways this could be implemented: > the user could change the code themselves and remove var $ = jQuery. Messy > at best, and forces people to serve the uncompressed version. > set a constant on the page before loading jQuery, eg var overWritePrototype > = false. Again, messy and ugly. > My favourite: support a 'hash' parameter in the url of the jQuery script, eg > http://path.to/jquery.js#$J . > > The script could check for such a hash, and if present, map jQuery to the > specified shortcut instead of $. This is an example implementation (which > works in firefox at least): new function(){ > var fileName, hash; > try { (null).fails } > catch(ex) { fileName = ex.fileName}; > hash = /#(.*)$/.exec(fileName); > window[hash ? hash[1] : '$'] = jQuery; > }; > > > > ...which would fall back to the same effect as var $ = jQuery; .This seems > like a good idea to me, but there might be something important I haven't > considered. > > - henrah > > _______________________________________________ > jQuery mailing list > [email protected] > http://jquery.com/discuss/ > > > _______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
