Greetings --

I have only recently begun using jQuery, so apologies in advance if my
question and proposal is way off base.

I'm using jQuery-1.2.6 within a Firefox extension.  For the most part
it works as-is, though there are some methods that do not work because
they use the "document" object.

My extension gets a handle to the document in the browser, so I have
been using code that looks like:
  $("#foo", docHandle).whatever...

Which works fine, but there are still many non-functioning methods
that do not have a context argument and are hardwired to use the
"document" object.

My solution was to create a class variable "root", whose default value
is "document" (output from diffing with 1.2.6)...

26a27,29
> // root element
>   root = document,
>

... then to add a method to change the value of "root"...

606a611,615
>   // change the root element (default is 'document')
>   setroot: function( elem ) {
>     root = elem;
>   },
>

... then to replace any instances of "document" in the jQuery source
with "root".
(approximately 40 occurences)

Once I get my document handle in my extension code, I call...
  jQuery.setroot(docHandle);

... and all is good.

This allows me to reset what "document" means to jQuery.  I can
imagine this could also allow a developer to set a global context for
other operations to restrict to certain parts of a webpage when jQuery
is used in the traditional sense.

Anyhow, I just wanted to get feedback from more experienced folks here
in case there's something glaring that I missed ... or in the slim
chance that this is actually a good idea, I can provide a full patch.

Regards,
-zs

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to