I’m having difficulty working with sliders. I can’t properly address a range slider. I have created 3 sliders. Now I want to get and set their value. But I can’t seem to get the right selector. this is the code that generates the 3 sliders (as suggested by “plpl”):
var $$=Dom7;
app.dialog.create({
title: 'Set RGB',
verticalButtons: true,
buttons:[{text:'OK'},{text:'Cancel'}],
on:{
open:function(d){
var els=d.$el.find('.range-slider');
for(var i=0;i<els.length;i++){
app.range.create({
el: els[i],
on:{
change:function(r){
console.log(r.getValue());
}
}
});
}
}
},
content:'<div class="block">\
<div class="range-slider color-red" data-label="true">\
<input id="redSlider" type="range" min="0" max="255" step="1" value="50">\
</div>\
</div>\
<div class="block">\
<div class="range-slider color-green" data-label="true">\
<input id="greenSlider" type="range" min="0" max="255" step="1" value="50">\
</div>\
</div>\
<div class="block">\
<div class="range-slider color-blue" data-label="true">\
<input id="blueSlider" type="range" min="0" max="255" step="1" value="50">\
</div>\
</div>'
}).open();
now how do I select for example the red slider?
This how I could do it: define a global variable at the top of JS var rangeSlider=[];
and then
for(var i=0;i<els.length;i++){ rangeSlider[i] = app.range.create({ el: els[i], on:{ change:function(r){ console.log(r.getValue()); } } }); }
this way I can use rangeSlider[1].setValue(200);
and it works. But I think I’m getting it the hard and inefficent way.