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

Tricky multiple slider scenerio

1 Answer 190 Views
Slider
This is a migrated thread and some comments may be shown as answers.
troy
Top achievements
Rank 1
troy asked on 16 Nov 2011, 01:00 AM
I have a dynamic list of sliders on a page and I am trying to limit the ability to increase sliders up to a defined amount.  

For example: There are 3 sliders, and they range from 0-10. There is a voting limit variable that is set to 10.  How Can I disable all sliders from increasing if the total value of all sliders is equal to the main Voting limit?

I know that my example here is very barebones, but I really need some help in determining the total of all the sliders and disabling only the increasing ability once it's reached.

<script>
    var max_votes = 10;
    var sliderTotals = getSliderTotals(max_votes);
         
    function getSliderTotals(val){
        return val;    
    }
     
    function sliderOnSlide(e) {    
        // the current value of the slider
        var orig_value = this.value();
         
        // the new value
        var new_value = e.value;
         
        if(new_value > orig_value){
            new_max_votes = (max_votes - new_value);
        }
    }
 
    function sliderOnChange(e) {
        //console.log("Slide :: new slide value is: " + e.value);
    }
 
    $(document).ready(function() {
        $(".slider").kendoSlider({
            showButtons: false,
            change: sliderOnChange,
            slide: sliderOnSlide
        });    
    });
</script>

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 16 Nov 2011, 10:04 AM
Hello Troy,

The Slider is not designed to allow a maximum value, which is smaller than its "real" maximum value. In your case the only thing you can do is intercept the change event of the widget, calculate the sum of all Slider values and reduce the value of the currently manipulated Slider if needed.

http://demos.kendoui.com/slider/events.html

http://demos.kendoui.com/slider/api.html

Best wishes,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Slider
Asked by
troy
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or