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

set slider value inside change event

1 Answer 950 Views
Slider
This is a migrated thread and some comments may be shown as answers.
TafnitDev
Top achievements
Rank 1
TafnitDev asked on 07 Aug 2016, 12:01 PM

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.

 


1 Answer, 1 is accepted

Sort by
0
Misho
Telerik team
answered on 09 Aug 2016, 11:14 AM
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.
 
Tags
Slider
Asked by
TafnitDev
Top achievements
Rank 1
Answers by
Misho
Telerik team
Share this question
or