ugh, I' min the same boat. I hope some of the superstars will
eventually get around to writing more detailed tutorials. been
struggling with extension writing myself.

On Mar 4, 11:09 am, Leanan <[EMAIL PROTECTED]> wrote:
> Ok, I'm really trying to wrap my head around this, and it's irritating
> me.  I've checked out the following pages:
>
> http://docs.jquery.com/Plugins/Authoringhttp://www.learningjquery.com/2007/10/a-plugin-development-pattern
>
> And they help some but there's one problem I'm running into.
>
> I have:
>
> $.fn.myPlugin = function(options) {
>   $.myPlugin.defaults = $.extend($.myPlugin.defaults, options);
>   return(this);
>
> };
>
> $.myPlugin = {
>   defaults: {
>     def1: 'default1',
>     def2: 'default2',
>     ...
>     defx: 'defaultx'
>   },
>
>   myFunc: function() {
>     var options = $.myPlugin.defaults;
>     //do something here, anything really
>   },
>
>   myFunc2: function() {
>       var options = $.myPlugin.defaults;
>       //do something here, again, anything
>   }
>
> };
>
> Now, I want to do something like this:
>
> jQuery().myPlugin({def1: 'other_def1', def2: 'other_def2'}).myFunc();
>
> Can I?
>
> Because it's not working.  It tells me that jQuery().myPlugin({def1:
> 'other_def1', def2: 'other_def2'}) is not a function.
>
> However, if I change it so that myFunc is $.fn.myFunc = function()
> { }, then I can, but I have to do it as:
>
> jQuery().myPlugin({def1: 'other_def1', def2:
> 'other_def2'}).myPlugin.myFunc();
>
> Which I don't like.
>
> None of the tutorials or documentation I can find is clear on this
> point, though they do refer to the functions in $.myPlugin as being
> user-accessable... and they are, but only if I do $.myPlugin.myFunc.
> I can't chain.  And I want to be able to do that.

Reply via email to