问题
I am using the noUISlider in my rails project.
noUiSlider.create( slider, {
start: [3],
connect: 'lower',
step: 1,
range: {
'min': 1,
'max': 9
},
pips: {
mode: 'steps',
density: 20
},
tooltips: true,
format: {
from: function(value) {
return (parseInt(value)+" days");
},
to: function(value) {
return (parseInt(value)+" days");
}
}
});
I want it to be a measure of days in the tooltip. So I added the format
part as above. But start: 3
wont work anymore. It starts from 1 instead. If I remove the format
, start
works fine.
I tried removing the format
and editing the noUi-tooltip text property from js (appending "days"), but that doesnt work either.
Any help ?
回答1:
In format
, the from
function converts the value from the formatted string to a numerical value. You'll want to cast your input to a number there:
format: {
from: Number,
to: function(value) {
return (parseInt(value)+" days");
}
}
来源:https://stackoverflow.com/questions/39361098/formatting-the-tooltip-in-nouislider