Create an empty object, pass it to the .each() block, and add each id as a
property of it as you go.

My first crack (which is probably hopelessly b0rked, but may get the point
across...):

var myInputs = {};
function sliderCallback { myInputs[this.id].rangeEl =
$(this).siblings().filter("input.range"); ...;  };
$(".slider").each( sliderCallback( myInputs ) );

I hope I'm on the right track...?

- Brian


> Is there a way to set a variable in an each that will be stored separately
> for each instance of the plugin (for example, if I am performing an action
> on all <input>s, is there a way to store the input type and reuse it
> later?). Maybe I'm not being clear, so here's the example:
>
>                 $(".slider").each(function() {
>                     rangeEl = $(this).siblings().filter("input.range");
>                     rangeEl.css("border", "1px solid green");
>                     rangeMax = parseInt(rangeEl.attr("max")) || 100;
>                     rangeMin = parseInt(rangeEl.attr("min")) || 0;
>                     rangeVal = parseInt(rangeEl.val()) || 0;
>                     step = parseInt(rangeEl.attr("step"));
>                     difference = rangeMax - rangeMin;
>                     differential = difference / 100.0;
>                     $(this).Slider({
>                         accept: ".indicator", fractions: (difference /
> step),
>                         onSlide: function(cordx, cordy, x , y) {
>                             rangeEl.val(parseInt((cordx * differential) +
> rangeMin))
>                         }
>                     });
>                     $(this).SliderSetValues([[234 * ((rangeVal - rangeMin)
> /
> (difference)),0]]);
>                     rangeEl.val(rangeVal);
>                 });
>
>
> What seems to be happening is that the rangeEl element is getting
> overwritten, and all sliders are using the same (last) element.



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to