I am writing my first jQuery plugin and I want to be able to do this:
var myPluginVar = $("someElement").myPlugin();
myPluginVar.customFunctionCallWithinPlugin();
Any idea how to go about it?
EDIT
Please visit http://flowplayer.org/tools/using.html#api to see what i mean
You could achieve this design with something similar to the following. I have wrapped the plugin definition within an anonymous function to keep
PluginObjfrom polluting the global namespace.The jQuery method returns a new object with the methods you define. This is a non-standard design for a jQuery plugin though, so if you plan to distribute it make sure it is thoroughly documented.