Hi all,

I was wondering what's the best approach to share settings between to 
jQuery functions?

The scenario is this: I want to add a bookmarkable: true|false option to 
the Tabs plugin to be able to switch off the changing hash in the URL.

No problem for the tabs function alone:

jQuery.tabs = function({ /* options object literal */ })

Unfortunately I have the other function triggerTab, that needs to know 
of that setting as well.

What is the best approach? Some ideas I had:

* Attach every options object as property to a tabs container? I guess 
this is the fastest solution. But is this clean?

* Maybe I can attach a custom event to the tabs (in the tabs function) 
and simply trigger that one in the triggerTab function (that would also 
proove, that I chose the name wisely :-) ). Jörn, you made some use of 
custom events, don't you? Who else?

* Taking an OO approach, wrap both functions into an instance of a class 
and have the settings at hand as private variable? Is that doable?
I would have to use apply for the chainable function to get "this" right 
I assume.

* Pass the same options object to the triggerTab function, but I think 
that's ugly.


I'm thankful for some help!


-- Klaus



_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to