javascript - Not able to understand how the domEvent works -
scenario:
i have radcombobox , have attached functions of events. 1 event of combobox onclientblur , using check whether value in combo "unassigned" or not. if "unassigned" need cancel onblur event , keep focus on same combo.
this javascript has been used cancel event.
if (sender.get_text() === "unassigned") { eventargs.get_domevent().preventdefault(); return false; }
problem:
when user tabs out first time of combobox event gets cancelled , focus stays on same combo box (in case 3rd combo).
but when user hits tab button again focus moves next control.
when debugged code found when user first hits tab button, following line works
eventargs.get_domevent().preventdefault();
i can see preventdefault function, see following snapshot.
but when user hits tab button again error , cannot see preventdefault function, see following snapshot
i not able understand going wrong here. anyhelp appreciated.
your problem, revolves around difference between mouseevents , keyevents. , way telerik implement onclientblur
event. far doesn't point specific type of browser event, each time gets triggered
as see in first snapshot got clientx
, clienty
, means onclientblur
derived mouseevent
.
whereas in second 1 got altkey
, altleft
, , there no button
property, means 1 keyevent
.
the other point here have these fields in output:
e.bookmarks e.behaviorpart e.behaviorcookie
means using 1 of old versions of ie4+ ie7 or ie8, have cancelbubble
instead of preventdefault
.
sometimes events not cancelable
, , using event.cancelable
can make sure if current event cancelable
or not.
at end fix code can this:
if (sender.get_text() === "unassigned") { var domevent = eventargs.get_domevent(); if(domevent.cancelable){ if(typeof(domevent.preventdefault)==="function") domevent.preventdefault(); else domevent.cancelbubble = true; return false; } else{ //you can not cancel event, else make manageable } }
Comments
Post a Comment