kendo ui - MVVM-KendoNumericTextBox restore previous value without triggering 'change' twice -


i'm using kendo mvvm , have kendo numerictextbox bound kendo observable. want is: when user changes value, confirm should pop saying 'are sure?' if yes -> no problem, go on. if no -> nothing should happen!

in theory sounds simple that... found 3 major issues:

1) numerictextbox got 2 events: spin , change... idea of using keypress/focus/or other event discarded.

2) tried using change event... can't preventdefault! try save previous value , restore in case of 'no answer' brings me trigger event change twice!

3) other model field 'observing' numerictextbox change before answer confirm box... , absolutely don't want this!

p.s. got dropdownlist , datepicker must work in same way!

help please!

provided fast example: http://dojo.telerik.com/eyite here can see how numericbox2 (who observing numericbox1 , computed) changes before user answer yes/no (problem 3) , keypress/focus/preventdefault doesn't work.

here answer binding events not supported default: kendo mvvm , binding or extending custom events

for preventdefault (or "reverting" value). tried store previous value suggested , not fire twice:

var viewmodel = kendo.observable({     myitem: {        // fields, etc       mynumericbox: 10,       mynumericbox2: function () {         return viewmodel.get("myitem.mynumericbox")*2;       },       tmp: 10     },     onchange: function (e) {         if ( confirm("are sure?")) {                 viewmodel.set("myitem.tmp", viewmodel.get("myitem.mynumericbox"));           }           else {               viewmodel.set("myitem.mynumericbox", viewmodel.get("myitem.tmp"));            }     },   tryf: function () {     alert("hello!"); // doesn't trigger   },   tryk: function() {     alert("hello2!"); // doesn't trigger   }  }); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -