EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: gordis gmbh on September 16, 2015, 09:47:46 AM



Title: reset on textbox / datebox / combobox triggers onchange
Post by: gordis gmbh on September 16, 2015, 09:47:46 AM
I have a series of textboxes with onchange function implemented to submit the changed value to the database.

If the database delivers an error, I try to restore the component's oldvalue using 'setValue'. But the 'setValue' call triggers the onchange function again and as a result the submit gets called again - resulting in a never ending loop!

Please find the demo here: http://jsfiddle.net/2xo0cyz9/ (http://jsfiddle.net/2xo0cyz9/)

What am I doing wrong here? I dont want to call reset on the textbox. I want to restore the previous value.

The same problem exists with date and comboboxes as well. Please help. Thanks.




Title: Re: reset on textbox / datebox / combobox triggers onchange
Post by: stworthy on September 16, 2015, 06:22:10 PM
Please call 'initValue' method instead of 'setValue' method. The 'initValue' method changes the textbox value but does not trigger the 'onChange' event.
http://jsfiddle.net/2xo0cyz9/1/


Title: Re: reset on textbox / datebox / combobox triggers onchange
Post by: gordis gmbh on September 17, 2015, 05:47:10 AM
Thanks very much for the reply. The initValue works as expected for textboxes and dateboxes.

However, for comboboxes it doesn't behave like setValue but does setText: http://jsfiddle.net/2xo0cyz9/3/ (http://jsfiddle.net/2xo0cyz9/3/)



Title: Re: reset on textbox / datebox / combobox triggers onchange
Post by: stworthy on September 17, 2015, 06:17:45 AM
Please try this updated example http://jsfiddle.net/2xo0cyz9/4/


Title: Re: reset on textbox / datebox / combobox triggers onchange
Post by: pkoziej on July 06, 2016, 09:50:52 AM
Sorry for waking up old topic but it is important for me.

It doesn't seem to work for me.

When I call such rollback function during onChange event I get strange situation that value of combobox is reset to oldValue but in ui it looks like new value was selected. So I have combobox displaying "YES" but when I check its value it is "NO"

Does anyone have runnig example how to successfully recover oldValue in combobox if for example database operation failed?