Currently, we rely on jQuery being mapped to $, however, we should not force users to use jQuery. Therefore, we should add a noConflict call and convert all instances of $ to jQuery.

CommentFileSizeAuthor
#2 jquery-noconflict.patch33.75 KBkkaefer

Comments

gábor hojtsy’s picture

This seems to be a very big change so late in the release cycle IMHO. It is quite disturbing for the current modules using jQuery.

kkaefer’s picture

Status: Active » Needs review
StatusFileSize
new33.75 KB

How many 6.x modules with js files are ported for 6 already? Besides, it is very easy to make a JS file compatible with jQuery.noConflict(): You just have to wrap the entire file in a inline function call and pass it jQuery as parameter to map it to $. See the attached patch for further information.

jrabeemer’s picture

I can see the benefit of other Javascript libraries like Prototype and Mootools benefiting. Since other libraries use $$ or $ object, this moves Drupal's jQuery out of the way. But if the user already has jQuery scripts for their existing sites, their JS code will break due to the missing $ mapping. They'll have to remap it globally. Also, just because remapping to jQuery doesn't guarantee it will fix OTHER JS libraries that make use of $/$$. This is a silly but plausible question, what if I choose to use Prototype and Mootools and jQuery at the same time?

dvessel’s picture

Looks like 1.1.4 provides just this and more.

http://jquery.com/blog/2007/08/24/jquery-114-faster-more-tests-ready-for...

I'd roll a patch myself but I can't invest the time.

nevets’s picture

I personally disagree with this request. My understanding was that a choice was made to pick a javascript library as the standard one used by Drupal and jQuery was picked. Having a consistent library makes it easier to had javascript/ajax functionality often with little code. As things now stand jQuery is the standard library used by Drupal making it easy to use other jQuery scripts for use on ones site. This seems like a step backwards to me.

profix898’s picture

I'd love to keep the simple/short $, but I also see the benefits of this patch. (subscribing)

dvessel’s picture

Another issue created here:

http://drupal.org/node/170224

Uses jQuery 1.1.4 and basically solves this same issue.

nedjo’s picture

Status: Needs review » Closed (duplicate)

The issue dvessel pointed to was committed, so apparently this is now fixed.

kkaefer’s picture

Status: Closed (duplicate) » Needs review

It does not sole the issue at all. jQuery 1.1.4 just has better support for supporting other libraries. We still need to wrap Drupal’s JS files in a separate namespace where we map $ to jQuery.

dvessel’s picture

Yup, the issue title was changed. Ended up just drop in 1.1.4.

nedjo’s picture

Thanks for reopening this, apologies, I should have read the other issue more carefully.

I'm not sure if this counts as something to apply post-freeze. Is it bug, or a feature request?

In any case it is indeed a useful patch and simple and painless change for us as contrib module maintainers.

gábor hojtsy’s picture

Version: 6.x-dev » 7.x-dev

We are not making such API changes this late in the cycle IMHO. Postponed.

catch’s picture

Status: Needs review » Closed (duplicate)