But what I want is just like JQuery UI plugin. I hope I can apply the above plugin on some elements separately so that I can apply different settings like this:
The main issue is that the i is indexed from each selector so when '#tab1, #tab2, #tab3' is used, it counts 0, 1, 2.
But when three separate calls to the plugin are made, the count always starts from 0. This is why the tab content is getting mixed between the instances.
So, the easiest solution is to apply a unique value to each call, so instead define i like this:
This works for multiple elements when I apply the plugin in a combined selector like this:
But what I want is just like JQuery UI plugin. I hope I can apply the above plugin on some elements separately so that I can apply different settings like this:
But why this concept does not work?
Do you have a better JQuery plugin pattern. But the simplest. Thanks a lot!
The main issue is that the
iis indexed from each selector so when'#tab1, #tab2, #tab3'is used, it counts 0, 1, 2.But when three separate calls to the plugin are made, the count always starts from 0. This is why the tab content is getting mixed between the instances.
So, the easiest solution is to apply a unique value to each call, so instead define
ilike this:Here is an updated demo.Also, it is good practice to target the tabs from it's own wrapper, so instead of depending on
ito be unique:find the tab this way:http://jsfiddle.net/tovic/yJ6Mg/7/
http://reader-download.googlecode.com/svn/trunk/SimpleTab/index.html