Using jQuery UI Range Slider, getting value

I use the jQuery UI slider to allow the user to increase / decrease the selection range, I need to know (according to the original value of the slider) if the user wants to increase or decrease.

Here is my function, I'm not sure where to put the code to extract the original value before changing it. Can anyone help me with this?

Any help / suggestions are welcome!

function createRangeSliderOutOfIframe(kinorid) {
    $("#slider-range" + kinorid).slider({
        animate: true,
        step: 1,
        min: 1,
        max: 6,
        value: 1,

        slide: function (event, ui) {

        },
        change: function (event, ui) {
            if (ui.value >= 1) {

                var add = '<span class="kSelectedA">Link</span>';

                $("#myFrame").contents().find('*').each(function () {
                    if ($(this).attr('kinorid') == kinorid) {
                        if (count == 0) {
                            $(result).parent().before(add);
                            count += 1;
                        }  
                        else if (count <= 6 && count != 0) {
                            result = $(this).parent();
                            for (i = 0; i < count; i++) {
                                result = $(result).parent();
                                //test += 1;
                            }
                            $(result).parent().before(add);
                            count += 1;

                            $('#trackingInfo').append('<br/>The range of the selection Increased<br/>The new range is now a' + $(result).parent().get(0).nodeName + 'node');
                            //alert(count);
                        }

                    }
                });

            }

        }
    });
    //$("#amount"+kinorid).val("$" + $("#slider-range" + kinorid).slider("value"));
    var value = $("#slider-range" + kinorid).slider("option", "value");
    alert(value);
}

thank

+3
source share
1 answer

In general, you can determine the initial value of the slider by clicking on the event: start

$("#selector").slider({ start: function(event, ui) { ... });

change stop, , :

var start = 0;
$("#slider").slider({
    start: function(event, ui) {
        // ui.value is the starting value
        start = ui.value;
    },
    stop: function(event, ui) {
        // now ui.value is the value the user set after stopping the sliding.
        $("#delta").text(ui.value > start ? "increasing" : "decreasing");
    }
});

, , . , : http://jsfiddle.net/andrewwhitaker/rwKsh/

+8

All Articles