jqueryjquery-slider

JQuery slider set value on create


$("#slider1").slider({
    min: 1940,
    max: 2013,
    values: [1990, 2013],
    range: true,
    slide: function (event, ui) {
        var val = ui.values;
        $('#from1').text(val[0]);
        $('#to1').text(val[1]);
        $('#i_from1').val(val[0]);
        $('#i_to1').val(val[1]);
    },
    create: function (event, ui) {
        alert(ui.values);
    }
});

when i make alert, i get undefined value, why is that?, i need to set those values to some html elements on create


Solution

  • Unfortunately in create handler, ui parameter doesn't have value property. You can use this instead:

    create: function (event, ui) {
        alert($(this).slider("values"));
    }