user1990 user1990 - 5 months ago 67
jQuery Question

How to get min and max range from price range slider?

I am using jQuery for getting min and max value from range slider but it's display nothing:

$j("#prise-range-input").ionRangeSlider({
type: "double",
grid: true,
min: 500000,
max: 15000000,
from: 500000,
to: 15000000,
prefix: "$",
stop: function( event, ui ) {
alert(ui.values[0]);
alert(ui.values[1]);
$j( "#stopvalue" ).val( "$" + ui.values[0] + " - $" + ui.values[1] );
}
});


It does not alert values can anyone tell me what wrong in this?

Answer

If you check the documentation for the IonRangeSlider plugin you'll see that there is no stop parameter in the settings object. The parameter you want to use when a range is changed is onFinish. This accepts a function which takes a single parameter which is an object containing the information about the slider's current state.

With that in mind, your code should be like this:

$j("#prise-range-input").ionRangeSlider({
    type: "double",
    grid: true,
    min: 500000,
    max: 15000000,
    from: 500000,
    to: 15000000,
    prefix: "$",
    onFinish: function(data) {
        console.log(data);
        $j("#stopvalue").val("$" + data.from + " - $" + data.to);
    }
});

Example fiddle