jQRangeSlider icon indicating copy to clipboard operation
jQRangeSlider copied to clipboard

Allow passing options object to existing rangeSlider to update several values at once

Open fscofield opened this issue 11 years ago • 3 comments

for example:


$('.my-slider').rangeSlider('options', {
    arrows: false,
    step: { months: 3 },
    range: { min: {months: 3} }
}); 



fscofield avatar Aug 12 '14 17:08 fscofield

Is there a simple way to do this that doesn't involve iterating like this:

_.each(options, function(val, key){
     $('.my-slider').rangeSlider('option', key, val);
})

fscofield avatar Aug 12 '14 17:08 fscofield

Sure, you can do this. It is not described clearly in the docs, but it works. This feature is supported by the jquery-ui widget, from which the slider is inheriting.

All you have to do is to call "option" (without an "s") and pass an object.

 $('.my-slider').rangeSlider('option', {
   arrows: false,
     step: { months: 3 },
     range: { min: {months: 3} }
 }); 

ghusse avatar Aug 18 '14 07:08 ghusse

Is there a way to do this for values as well?

Does not work (only bounds are updated):

$('#time-control').dateRangeSlider('option', {
  bounds: {min: sod, max: eod},
  values: {min: selMin, max: selMax}
});

This works, updates both bounds and values (but this triggers the valuesChanged event twice):

$('#time-control').dateRangeSlider('bounds', sod, eod);
$('#time-control').dateRangeSlider('values', selMin, selMax);

I've tried using 'defaultValues' when setting options, but that doesn't work either.

joakimtonnesen avatar Aug 19 '14 09:08 joakimtonnesen