smanvi12
smanvi12

Reputation: 581

formatting the tooltip in noUISlider

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 ?

Upvotes: 3

Views: 4491

Answers (1)

Lg102
Lg102

Reputation: 4898

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");
    }
}

Upvotes: 3

Related Questions