812 posts
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • Serbia
  • Has been a member for 5-6 years
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
  • Bought between 1 and 9 items
  • Brazil
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
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() ?

812 posts
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • Serbia
  • Has been a member for 5-6 years
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