Hi all,

I'm looking for a way to collect non-static functions under one plugin
name, because the non-static members cannot access the "this" value.

This is how I would collect static functions in a plugin:
       $.myplugin= {
                branch : {
                        sub1: function(){...},
                        sub2: function(){...}
                },
                branch2 : {
                        sub1: function(){...}
                }
        };

Thus $.myplugin.branch.sub1() works would work.

Unfortunately non-statics don't work as well.  Here is what I have so
far:

        $.fn.myplugin= {
                branch: function(){
                                return this.each(function(){
                                        alert("in branch");
                                        return $;
                                });
                }

As you can see I'm trying to enable:  $("p").myplugin.branch()
But because the "this" has the wrong scope I cannot access the this.
(The compile error is "this.each is not a function").  For the time
being I'm going to make it as $("p").myplugin().branch(), but that
seems a little less attractive.  Any ideas?  I wish something like $
(this) would work, or even $("this") would help get the last query
from jquery but such an option would have to be global.

Any thoughts?  Thanks in advance for your help!

Evan






Reply via email to