815 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 1
  • Freebie
+3 more
rvision_
says

I’m writing a plugin for some kind of slider and I am having a strange issue:

I want it to be chainable (as all jQuery plugins should be). And I am having a strange problem here: when plugin is called on a array of elements (3 of them on the page), like this:

$(".slider").slider();

plugin doesn’t work properly. But when it’s called like this:

$("#slider1").slider(); $("#slider2").slider(); $("#slider3").slider();

Everything works fine.

Do you have any suggestions what might be the problem? Or where can I find more information about this issue?

thanks

147 posts
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 4
  • Brazil
+2 more
zecchin
says

edit: i guess i get what you mean, i had given a answer but i guess you want that every element with that said class works as a slider?

jQuery.each() ?

815 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 1
  • Freebie
+3 more
rvision_
says

Sorry, wrong question – late night, end of the work week and power indicator is low :)

Yes, what I should have ask is how to get the plugin work for multiple elements, not chainability (this works BTW ).

I’ve found solution :

// support for mutiltiple elements: if (this.length > 1){ this.each(function() { $(this).slider(options) }); return this; }

Thanks anyway!

by
by
by
by
by
by