获取ion.rangeslider值,按价格和底部的所有滑块总数

时间:2016-02-10 06:58:14

标签: jquery rangeslider

使用此代码集:http://codepen.io/anon/pen/RrEbjB

每个滑块每个15美元,我需要调整滑块以更新底部的总数。所有3个应该适用于总数。

任何帮助都会受到赞赏,让回调工作,我删除了我正在处理的代码,因为它只是破坏了一切......

$(function () {

    $("#range1").ionRangeSlider({
        min: 0,
        max: 100,
        hide_min_max: true
    });

    $("#range2").ionRangeSlider({
        min: 0,
        max: 100,
        hide_min_max: true
    });

    $("#range3").ionRangeSlider({
        min: 0,
        max: 100,
        hide_min_max: true
    });

});

1 个答案:

答案 0 :(得分:0)

我想为其他用户着想,我会发布最终为我工作的代码。

function sum () {
    var total = (a * 15) + (b * 15) + (c * 15);
    $total.text(total);
}

function sum2 () {
    var totals = (a * 15) + (b * 15) + (c * 15);
    var k = Number(totals) + Number( $('#other_amount').val());
    $grand_total.text(k);
}

$('#other_amount').change(function() {
    sum2();
});

$("#range1").ionRangeSlider({
    min: 0,
    max: 25,
    postfix: " in Basket",
    hide_min_max: true,
    hide_from_to: false,
    grid: true,
    keyboard: true,
    keyboard_step: 1,
    force_edges: true,
    onChange: function (data) {
        a = data.from;
        sum();
        sum2();
    }
});

$("#range2").ionRangeSlider({
    min: 0,
    max: 25,
    postfix: " in Basket",
    hide_min_max: true,
    hide_from_to: false,
    grid: true,
    keyboard: true,
    keyboard_step: 1,
    force_edges: true,
    onChange: function (data) {
        b = data.from;
        sum();
        sum2();
    }
});

$("#range3").ionRangeSlider({
    min: 0,
    max: 25,
    postfix: " in Basket",
    hide_min_max: true,
    hide_from_to: false,
    grid: true,
    keyboard: true,
    keyboard_step: 1,
    force_edges: true,
    onChange: function (data) {
        c = data.from;
        sum();
        sum2();
    }
});