I'm trying to get the min and max value from a bootstrap
range slider. I want both values to use in an array.
I have this function
:
var slider = new Slider('#periodslider', {
formatter: function(value) {
var period = ['1-1/Jaar-2', '1-6/Jaar-2', '31-12/Jaar-2', '1-1/Jaar-1', '1-6/Jaar-1', '31-12/Jaar-1'];
//return period[value - 1];
}
});
What I want is to use the min value to label the value to a label within the period array. Same goes for the max value.
With a normal slider I use this function
:
var slider = new Slider("#frequencyslider", {
//tooltip: 'always',
formatter: function(value) {
var frequency = ['Maand', 'Kwartaal', 'Jaar'];
return frequency[value - 1];
}
});
This doesn't work for what I want becaus with a range slider it outputs the values as: 1:5
I found the solution: the docs of bootstrap-slider.js
pointed out that in the case of a range slider, the value type isn't float
but an array
.
To get what I wanted, I made the function like this:
var slider = new Slider('#periodslider', {
formatter: function(value) {
var period = ['1-2013', '7-2013', '1-2014', '7-2014', '1-2015'];
return period[value[0]] + " tot " + period[value[1]];
}
});
This works perfectly!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.