Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

noUiSlider get raw value

I'm using noUiSlider and followed the tutorial how to create custom formatting:

noUiSlider.create(sliderFormat, {
start: [ 20 ],
step: 10,
range: {
    'min': [ 0 ],
    'max': [ 599 ]
},
format: {
  to: function ( value ) {
    return Math.round(value/60) + ':' + Math.round(value%60);
  },
  from: function ( value ) {
    return value;
  }
}
});

When I call

mySlider.get()

it returns a value like 1:10, which is the formatted value. I would like to get the raw value (like 70 in this example), how is that possible?

like image 755
Torsten Simon Avatar asked Mar 02 '26 23:03

Torsten Simon


1 Answers

As Vaibhav Kumar suggestet, I used the update function to read the raw value:

slider.noUiSlider.on('update', function(values,handle,unencoded){
   // unencoded contains the raw value
});
like image 141
Torsten Simon Avatar answered Mar 04 '26 13:03

Torsten Simon