|
Title: reset textbox on escape (esc) key Post by: gordis gmbh on September 23, 2015, 03:30:47 AM A textbox exists with text "test" in it. The user begins to type in that textbox and presses escape key to undo editing such that the value "text" is restored again.
In keydown bind function, I call reset on textbox but that sets the textbox empty: Quote $.fn.textbox.defaults = $.extend({},$.fn.textbox.defaults,{ inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{ keydown:function(e){ if(e.keyCode == 27){ var target = e.data.target; $(target).textbox('reset'); } } }) }); How can I reset the value that was there prior to edit? Title: Re: reset textbox on escape (esc) key Post by: stworthy on September 23, 2015, 08:08:18 AM To set the initialized value, you have to set the 'value' when creating the textbox. Please take a look at the code below, the textbox is created with an initialized value. When calling 'reset' method, the value will be reset to its original value. i.e. 'initialized value'.
Code: $('#tt').textbox({Title: Re: reset textbox on escape (esc) key Post by: gordis gmbh on September 25, 2015, 04:57:09 AM The textboxes are defined once and filled conditionally using 'initValue'. The user may edit the text which is saved onChange. Now I want to add 'escape key' functionality to reset the textbox with value that was set prior to edit. I have made an example of what I mean:
http://jsfiddle.net/2hy9jz2h/3/ (http://jsfiddle.net/2hy9jz2h/3/) If you try to edit say street for employee1 and press escape, the textbox is set to empty. How can I use the option 'value' here? I did try to set the value using Code: $('#streetTB').textbox('options').value = 'some value'; Title: Re: reset textbox on escape (esc) key Post by: stworthy on September 25, 2015, 09:11:51 AM Please try this updated example http://jsfiddle.net/2hy9jz2h/4/
|