I'm new to Javascript and JQuery, I am trying to use JQuery UI Slider to replace price range dropdown boxes(one for Minimum Price, another for Maximum Price) for one of my sites.
Here is my current code:
$(function() {
var slider = $( "#slider-range" ).slider({
range: true,
min: 0,
max: 2500000,
step: 1000,
values: [ 0, 2500000 ],
slide: function( event, ui ) {
$( "#amount" ).val( "RM " + commafy(ui.values[ 0 ]) + " to RM " + commafy(ui.values[ 1 ]) );
}
});
$( "#amount" ).val( "RM " + commafy($( "#slider-range" ).slider( "values", 0 )) +
" to RM " + commafy($( "#slider-range" ).slider( "values", 1 )) );
function commafy(val) {
return String(val).split("").reverse().join("")
.replace(/(.{3}\B)/g, "$1,")
.split("").reverse().join("");
}
});
The price range is from 0 to 2500,000. After testing I found out that UX will be better if the slider scales non-linearly as most of the users on my site would search between the 25,000 to 200,000 range.
A very minute portion of the slider should show the 0 to 25000 range, 70% of it showing 25,000 to 200,000 while the rest should show 200,000 and above. I don't want it to snap to fixed values but the steps has to be 1000.
I found two solutions on this site:
1) Logarithmic slider <- The solution wasn't based on the using the JQuery UI slider so I don't really know how to apply into my code.
2) JQuery Slider, how to make "step" size change <- I can't make heads or tails of it after the guy started using truevalues and values as part of the solution. I tried applying to my code, the slider works fine (Though moved too fast towards the end for my taste) but the text did not show.
Any ideas?