Hi Trey
I'm trying to use your jquery.plugin.js as a basis for creating a
plugin. I've got to :
$.plugin.add('plugin_name', {
init: function(options) {
return this;
},
another_method: function() {
}
});
But when I load the page I get a failure inside jquery.plugin.js
because of this line inside _add(fn, name, func):
applyTo[name].fn = applyTo[name].prototype = _constructor.prototype =
func.fn = func.prototype;
func is my object hash of functions, so it does not have a
func.prototype. This obviously causes all the assignments on that line
to be undefined, which causes errors when they are referenced.
Am I missing something in my code?
Cheers
Lee
On Mar 30, 11:50 pm, tres <[email protected]> wrote:
> Btw, Daniel, I have changed the API to accomodate this.
>
> jQuery.plugin.add('name', func || objectOfFuncs), will now add a
> static plugin and can be called like jQuery.name() or
> jQuery.name().method1();
>
> Static methods can be applied also by giving a static keyword with the
> function name:
>
> jQuery.plugin.add('name', {
> someInstanceMethod : fucntion() {},
> 'static:myStaticMethod' : function() {}
>
> });
>
> then can be called: jQuery.name().someInstanceMethod() or
> jQuery.name.myStaticMethod();
>
> and
>
> jQuery.fn.plugin.add('name', func || objectOfFuncs), will add it to
> jQuery's prototype and can be called jQuery('selector').name().
>
> jQuery.plugin.remove('name') and jQuery.fn.plugin.remove('name') work
> in a similar way.
>
> I'm putting together a full documentation and examples soon.
>
> -Trey
>
> On Mar 5, 1:34 pm, Daniel Friesen <[email protected]> wrote:
>
> > I think it could do with the ability to handle methods on jQuery itself
> > instead of being limited to just jQuery.fn, perhaps a second
> > object/function to addPlugin;
>
> > Likewise I'd prefer jQuery.options over jQuery.fn.options;
>
> > ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://nadir-seen-fire.com]
> > -Nadir-Point & Wiki-Tools (http://nadir-point.com) (http://wiki-tools.com)
> > -MonkeyScript (http://monkeyscript.org)
> > -Animepedia (http://anime.wikia.com)
> > -Narutopedia (http://naruto.wikia.com)
> > -Soul Eater Wiki (http://souleater.wikia.com)
>
> > [email protected] wrote:
> > > There has been a lot of activity about plugin authoring and how it can
> > > be more structured and extensible. I've posted a couple of comments on
> > > some threads and sent an email to John, but I thought I'd create a new
> > > thread since I haven't had any feedback yet. John, I understand you
> > > probably get a lot of email and are very busy.
>
> > > I've written a plugin that I'd like to get feedback on from you guys.
> > > It's still evolving, but should be stable in what it currently is
> > > designed to do and I have found it invaluable when authoring larger,
> > > more advanced plugins. It would be nice to see similar functionality
> > > built into jQuery as I think others would also find it useful.
>
> > > Link:http://plugins.jquery.com/project/plugin-authoring
>
> > > Cheers,
> > > Trey
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---