Another "solution" i found on a Blog.
Instead of adding a function to the Plugin, create a seperate object
within the scope of the plugin.
;(function($)
{
$.fn.pluginname = function(options)
{
// private method
function _doSomethingPrivate()
{
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
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 me
> i have a problem with the understanding of public methods of an
> plugin. Specialy how to create and link them to the plugin.
>
> For example:
>
> ;(function($)
> {
> $.fn.pluginname = function(options)
> {
> var _options = $.extend(
> {
>
If you declare the public method inside $.fn.pluginname then it will
be able to access the private things too, but this way the public
function won't be declared just after $().pluginname() was called. So
you can't call $.fn.pluginname.doSomethingPublic() before that.
But you can get around this
Is there realy nobody out there, who can point me into the right
direction?
A link to a tutorial would be already great.
If somebody doesn't understand the question, please tell me, i will
try to explain it further.
6 matches
Mail list logo