Here I have a problem with jQuery slider, were I get min
and max
values dynamically from a API, so when the value of max
, is in zero floating (like 0.27...), then I can not move the slider from left to right.
Please have a look into the attached image
in this, the first input box (min) holds the value zero, and the second input box (max) holds the value zero floating (0.27...) In this case i can not drag the slider left to right,
var calculateStep = function (minVal, maxVal) {
var difference = maxVal - minVal;
var step = parseInt(difference / 100);
return step;
};
var sliderStep = calculateStep(cfg.minVal, cfg.maxVal);
$(filter_wrap).find('.slider').slider({
range: true,
min: cfg.minVal,
max: cfg.maxVal,
step: sliderStep,
values: [cfg.minVal, cfg.maxVal],
slide: function (event, ui) {
//some code here
}
});
The function calculateStep
should be have logic to handle any kind of min
and max
, I think, but not sure, how to handle it.
Please help me in solving this issue.
try changing
var step = parseInt(difference / 100);
to
var step = parseFloat(difference / 100);