Rectangle 27 0

php How do I dynamically change min,max values for jquery ui slider?


$.get("ajax.php",options,function(data){
    $('.middle_container').html(data);          

    $('#slider-range').slider( "option", "min", $('.middle_container').find('.start_price').val() );
    $('#slider-range').slider( "option", "max", $('.middle_container').find('.end_price').val() );
    $('#slider-range').slider( "option", "value", $('#slider-range').slider("value"));

});

Make sure $('.middle_container').find('.start_price').val() and $('.middle_container').find('.end_price').val() are returning proper values. Also to set the value of the slider you have to use the same syntax which you are using for setting min/max values. Also

how do i access each of the values separately? because this is a range so there are two handles

Note
Rectangle 27 0

php How do I dynamically change min,max values for jquery ui slider?


$.get("ajax.php",options,function(data){
    $('.middle_container').html(data);          

    $('#slider-range').slider( "option", "min", $('.middle_container').find('.start_price').val() );
    $('#slider-range').slider( "option", "max", $('.middle_container').find('.end_price').val() );
    $('#slider-range').slider( "option", "value", $('#slider-range').slider("value"));

});

Make sure $('.middle_container').find('.start_price').val() and $('.middle_container').find('.end_price').val() are returning proper values. Also to set the value of the slider you have to use the same syntax which you are using for setting min/max values. Also

how do i access each of the values separately? because this is a range so there are two handles

Note
Rectangle 27 0

php How do I dynamically change min,max values for jquery ui slider?


$("#selector").slider("destroy");
$("#selector").slider({
    range: "max",
    min: 0, // min value
    max: 200, // max value
    step: 0.1,
    value: 200, // default value of slider
    slide: function(event, ui) {
        $("#amount").val(ui.value);
    }
});

After that you can add new values to the slider as,

Destroy the slider first, which removes the slider functionality completely. This will return the element back to its pre-init state.

Note
Rectangle 27 0

php How do I dynamically change min,max values for jquery ui slider?


$("#selector").slider("destroy");
$("#selector").slider({
    range: "max",
    min: 0, // min value
    max: 200, // max value
    step: 0.1,
    value: 200, // default value of slider
    slide: function(event, ui) {
        $("#amount").val(ui.value);
    }
});

After that you can add new values to the slider as,

Destroy the slider first, which removes the slider functionality completely. This will return the element back to its pre-init state.

Note
Rectangle 27 0

php How do I dynamically change min,max values for jquery ui slider?


$('#inputid').focusout(function() {

    // slider destroy and create as Shailesh showed
});

I was going to use keyup instead of focus, but depending on the internal checks you make, you could end up rebuilding your slider many times which would not be a benefit as you wont use it until you moving on from the input.

If you want to do this on an input value changing you can do something like this.

Note