EasyUI Forum
September 13, 2025, 11:03:07 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: reset on textbox / datebox / combobox triggers onchange  (Read 12143 times)
gordis gmbh
Full Member
***
Posts: 103


View Profile Email
« 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/

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.


Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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/
Logged
gordis gmbh
Full Member
***
Posts: 103


View Profile Email
« Reply #2 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/

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: September 17, 2015, 06:17:45 AM »

Please try this updated example http://jsfiddle.net/2xo0cyz9/4/
Logged
pkoziej
Newbie
*
Posts: 1


View Profile Email
« Reply #4 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?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!