815 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Contributed a free file of the month
+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
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in 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
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Contributed a free file of the month
+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