This is a migrated thread and some comments may be shown as answers.

Multiple Sliders Slide event

2 Answers 77 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 04 Sep 2012, 07:27 PM
I have multiple sliders on one page, meant to update a Radial Gauge using mathematical equations happening in the background as each slider is changed. All is working well.

However, it's been requested that I use the "slide" event instead of "change" to be more visually appealing. I know how to use the "slide" event handler for a single slider, but now I need to use the values for multiple sliders upon each slider's "slide" event.

The problem is that using options.value appears to be one value behind when using multiple sliders, as opposed to when it happens. How can I grab the current values of all sliders INCLUDING the value of the one that's currently being changed? I can only seem to do one or the other, instead of both types of values.

This is what I'm currently using:
function get_sum_prod_2(e) {
    arry_smpr = [0.285811679343038, 0.125446827004167, 0.216179632937688, 0.201202024564389, 0.211742022094242, 0.373720493554278, 0.148421270571020];
    x = 0;
    for(i = 0 ; i < 7 ; i++) {
        x += $("#sldr_" + (i + 1)).data("kendoSlider").options.value * arry_smpr[i];
    }
    console.log(x);
}

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 05 Sep 2012, 06:25 AM
Hello Angelo,

If you correctly use the slide event's e.value argument, you will obtain the current value.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mike
Top achievements
Rank 1
answered on 05 Sep 2012, 01:23 PM
Thanks. I figured it out. For anyone needing the same functionality, this is what I used (had to add current slider ID to change function):
function get_sum_prod(e, curr_id) {
    sum_prod = (e.value * arry_smpr[curr_id - 1]);
    for(i = 0 ; i < $("#divs_drvr .tile_sldr").length ; i++) {
        if(i != (curr_id - 1)) {
            sum_prod += $("#sldr_" + (i + 1)).data("kendoSlider").options.value * arry_smpr[i];
        }
    }
 
    $("#cont_drvr").data("kendoRadialGauge").value(sum_prod);
}
Tags
Slider
Asked by
Mike
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Mike
Top achievements
Rank 1
Share this question
or