Search code examples
jqueryjquery-uislideruislider

jQuery UI multiple sliders start amount the same?


I am busy with the jQuery UI sliders and now i have a problem.

I have multiple sliders and the range sliders have now the same start amount (0) as the signle sliders?

How can i fix this? I have made a JSFiddle: http://jsfiddle.net/ut2Uv/


Solution

  • If have the fix found myself:

    $(".range-slide").each(function() {
        var $this = $(this);
        $(".slide", $this).slider({
            values: [30, 60],
            min: 0,
            max: 100,
            range: true,
            slide: function(event, ui) {
                $("span.amount", $this).html("" + ui.values[0] + " - " + ui.values[1]);
            }
        });
        $(".range-slide span.amount").html("" + $(".slide").slider("values", 0) + " - " + $(".slide").slider("values", 1));
    });
    
    $(".signle-slide").each(function() {
        var $this = $(this);
        $(".slide", $this).slider({
            value: 0,
            min: 0,
            max: 100,
            slide: function(event, ui) {
                $("span.amount", $this).html("" + ui.value);
            }
        });
        $(".signle-slide span.amount").html("" + $(".slide").slider("value"));
    });