formatting the tooltip in noUISlider

北城以北 提交于 2019-12-10 23:22:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!