It depends on what the public method returns. If it returns the jQuery
object (the 'this' inside the plugin) then you have to call $
('#example').pluginname.doSomethingPublic().pluginname.doSomethingElse().

If you want to chain your methods directly you have to return 'this'
inside your public methods, which refers to $.fn.pluginname (not to
the jquery object!).
But doing this will prevent you from chaining jquery methods (most of
the plugins are chainable). If you don't like this and would like to
get the jquery object back, you can do that with another public
method:
$.fn.pluginname.returnJQuery = function(){  return _jquery;  }
where _jquery is defined where your _options object: var _jquery=this;
so $().pluginname.doSomethingPublic().doSomethingElse().returnJQuery()
will return the original jQuery object.

The only problem(?) with both is that it's a bit different from how
jQuery is generally used. That's why, I think, the jMaps approach is
somewhat better.


On szept. 3, 14:32, mwk <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Wow, thanks to both of you. Wouldn't have thought about such an
> construct. Maybe because i'm not that familiar with javascript at all.
> Somehow i thought you can't access an object while creating it.
> But also the way Balazs was mentioning about jmap looks interesting. I
> will have a closer look into it soon.
> For now i will try out the way mentioned above.
> The only thing i don't like in this solution is, that after calling
> the method u can't add another right after like :
>
> $('#example').pluginname.doSomethingPublic().doSomethingElse();
>
> is there a solution to it, except the way jmap does.

Reply via email to