This topic is relevant because there are people asking how to enable
manipulation on a jQuery plugin instance for plugin authors. I could
not find a good answer to this. jQuery makes code simple and beautiful
but has the side effect of locking away the ability to manipulate a
plugin instance as far as I can tell unless you have a singleton
approach. I'm fairly new to jQuery so forgive my ignorance if I missed
this already being supported or documented. I have not found any
documentation on this however.

I would like to know the preferred way for enabling instance
manipulation on a jquery plugin. I have rolled my own way of doing
this by passing in an empty object as an option parameter, then the
plugin adds public methods onto the object so the object's creator can
call those methods outside of the plugin. I found this to be fairly
simple and intuitive once you got your object reference because it
bring it back to the familiar.

An example of what I'm talking about is this: I created a simple
plugin to transition images -> 
http://storage.sebringcreative.com.s3.amazonaws.com/jquery/dumbCrossFade.htm
. A client later asked me to make them a slideshow with thumbnails
that had transitions. I decided to use my plugin but wanted to extend
it to allow for the capability of a consumer to be able to manipulate
the instance so they could write something easily that could use the
plugin only for what it needs to do but easily add functionality
around it to create something more. I ended up with this:
http://storage.sebringcreative.com.s3.amazonaws.com/jquery/slider.htm
. You can see the consumer code is just using the plugin for what it
does only and then adds its flavor on top to get the slideshow with
thumbs to work with very little code.

I would prefer to do it the correct way in the future since I have
plans on making a nice image slider with thumbnail capability and
thumbnail animation scroller as a full jquery plugin.

Reply via email to