I tried to do something like this a couple of months ago, and you
really can't do it efficiently.  This method is the only real way to
do it

"$('div ul').myNamespace().myMethod();"

And it is pretty messy.

If you really wanted to do it this way "$('div
ul').myNamespace.myMethod()," you would have to bind the scope of each
$ call to each method that is apart of your myNamespace object.

You could also make you own static method that uses a jQuery object
with your methods.

$.myNamespace = function(selector) {
  this.instance = $(selector);
};
myNamespace.prototype = {
  myMethod : function() {
    //do what ever
    // this.instance will be the jQuery object
  }
};

On Mar 28, 7:58 am, Julian Aubourg <[email protected]> wrote:
> I don't think it is possible. No matter how you turn it around, you'll lose
> the object context.
>
> I suppose your myNamespace() function is something like:
>
> $.fn.myNamespace = function() {
>   return this;
>
> }
>
> right?
>
> 2009/3/28 iceman2g <[email protected]>
>
>
>
> > I asked this elsewhere and it was suggested that I ask here.
>
> > So here goes
>
> > I was curious if it's possible to extend jquery to do something along
> > the
> > lines of "$('div ul').myNamespace.myMethod();"?
>
> > So far the closet I've seen anyone come to this, is along the lines of
> > "$('div ul').myNamespace().myMethod();".
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
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