Skip to main content

Bug Tracker

Side navigation

#6719 closed bug (worksforme)

Opened June 24, 2010 06:08PM UTC

Closed June 25, 2010 01:47AM UTC

Last modified March 15, 2012 01:12PM UTC

jQuery.noConflict() leaves $ undefined

Reported by: sebringj Owned by:
Priority: Milestone: 1.4.3
Component: unfiled Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

jQuery.noConflict() will leave $ undefined if no previous library has claimed it. The behavior should keep the $ defined if jQuery is the only library claiming it. The work around was this:

jQuery.noConflict();

if (typeof(window.$) === 'undefined') { window.$ = jQuery; }

The scenario is useful when loading in dynamic scripts that depend on jQuery and will load in jQuery if jQuery is undefined but then will allow other libraries to use the "$" or will leave the "$" defined to jQuery. The "$" is defined in other script libraries so this is necessary but it is not necessary for "jQuery" as it would be silly to support that if an idiot decided to define that. The "jQuery" fallback code should be taken out in my opinion to give room for this scenario as it is more likely than "jQuery" being defined from another library or code outside of the jQuery official code base.

Attachments (0)
Change History (1)

Changed June 25, 2010 01:47AM UTC by dmethvin comment:1

resolution: → worksforme
status: newclosed

I don't think we'll be changing this, it's been documented behavior for several years now and your solution works fine for the situation where you want it that way.