Reputation: 301
I'm using JQuery's slider widget with non-linear values. Basically, I have my slider set up like this
function configSlider(p_propertyName, p_sliderSteps) {
var slider_values = p_sliderSteps.split(',');
//build slider
var slider_selector = "#slider_" + p_propertyName;
var slider = $(slider_selector).slider({
value: 0,
min: 0,
max: slider_values.length,
change: function (event, ui) {
calculateSomething(
$('#slider1').slider_values[$('#slider1').slider('value')],
$('#slider2').slider_values[$('#slider2').slider('value')],
$('#slider3').slider_values[$('#slider3').slider('value')]);
},
}
var slider_values has the actual values of the slider. I need the values of two other sliders as well passed into calculateSomething above. I know why this won't work but are there any solutions that would be similar to mine?
Is there anyway to create a new var within the slider object?
Upvotes: 0
Views: 151
Reputation: 29941
Yes, you can use jQuery's data()
to assign arbitrary data to an element:
$("#slider1").data("slider_values", slider_values);
And then, to retrieve it:
var slider1Values = $("#slider1").data("slider_values");
Upvotes: 1