set slider value inside change event

2 posts, 0 answers
  1. TafnitDev
    TafnitDev avatar
    1 posts
    Member since:
    Jul 2013

    Posted 07 Aug Link to this post

    I have a page with kendoui slider, where i am checking if slider value is valid inside slider change event.
    If value isn`t valid, i want to roll back slider value to previous value,  
    But every time i set slider value (roll back to previous value) inside change event it doesn't work. 
    For instance, mySlider initial value is 2.
    The user is trying set the value to 10 but my validation function returns false (illegal value) and set my Slider back to it's initial value (2).
    For some reason, right after that, the value of my Slider has been set up to 10 (the user choise) again(!!)
    So practically my validation function has no meaning!!
    It happens inside kendo.all.js in the function :

    trigger: function (eventName, e) {
                    var that = this, events = that._events[eventName], idx, length;
                    if (events) {
                        e = e || {};
                        e.sender = that;
                        e._defaultPrevented = false;
                        e.preventDefault = preventDefault;
                        e.isDefaultPrevented = isDefaultPrevented;
                        events = events.slice();
                        for (idx = 0, length = events.length; idx < length; idx++) {
                        events[idx].call(that, e); ////////////////////////////////////////////////Here it change back to the user choise    
                        }
                        return e._defaultPrevented === true;
                    }
                    return false;
      },

    My Code:

    var slider =$("#slider").kendoSlider({
    orientation: "vertical",
    smallStep:1000,
    largeStep:5000,
    min:0,
    max:100000,
    value:50000,
    change:Calc
    });

    function Calc(e){
        if (!(IsValid(e.value)))
       {
          $("#slider").data("kendoSlider").value(prevVal);
       }
    }   ////////////////////////////////////////////////Here it calls to:trigger: function (eventName, e) which written above

    Is there some any way to do it?

    Tanks.

     


  2. Misho
    Admin
    Misho avatar
    129 posts

    Posted 09 Aug Link to this post

    Hi,

    We have created the following demo that is showing how to use Kendo slider API:
    http://demos.telerik.com/kendo-ui/slider/api
    You can use the following sample as a reference:

    http://dojo.telerik.com/@parvanov/iSIyOJ

    I hope that helps.

    Regards,
    Misho
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
Back to Top