Skip to main content

Bug Tracker

Side navigation

#1393 closed enhancement (fixed)

Opened July 13, 2007 01:45AM UTC

Closed August 22, 2007 05:47AM UTC

Last modified March 15, 2012 01:08AM UTC

Assigning jQuery to an existing namespace

Reported by: Byron Owned by: john
Priority: major Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: namespace, 'this' Cc:
Blocked by: Blocking:

I've started using jquery in the development of a firefox extension.

generally when developing extensions i like to keep all my properties and functions etc in one global namespace, im not sure if this is the best approach but its worked pretty well in the past when it comes to avoiding namespace collisions.

example :

var myObject = {

config : {

debug : true


init : function () {..}


now after a bit of thought, i realised someone else might decide to

use jquery in their extension or use the '$' namepace for something else.. then I thought "No Problem jQuery.noConflict() to the rescue!"

so off I went to try it out;

myObject.$ = jQuery.noConflict();

didnt work...

so then i tried some different combinations.. = jQuery.noConflict();

myObject.prototype.$ = jQuery.noConflict();

var jBuf = jQuery.noConflict();

myObject.$ = jBuf;

by now i was getting frustrated (as is probably evident in this


So is there any way to do it like this or will i have to use a

seperate namespace for jquery?


Attachments (0)
Change History (5)

Changed August 21, 2007 06:47AM UTC by john comment:1

owner: → john

Changed August 21, 2007 07:00AM UTC by john comment:2

resolution: → fixed
status: newclosed

Fixed in SVN rev [2819].

Changed August 21, 2007 04:15PM UTC by john comment:3

From Arrix:

  • There should be some way to unroll 'jQuery' from the global object.
  • new Function() should become eval('function(){...}') to catch jQuery in its scope
  • Expandos need a prefix so that they don't overlap

Changed August 21, 2007 04:18PM UTC by john comment:4

resolution: fixed
status: closedreopened

Changed August 22, 2007 05:47AM UTC by john comment:5

resolution: → fixed
status: reopenedclosed

I committed the first two points in SVN rev [2833], but changing the last one would cause the API to break (since plugins rely on the $events expando). I think this is ok for now, but I'll try to think of a better solution.