Title: Avoid the "onSelect" event to run during the initial loading of form data Post by: rezzonico on December 25, 2016, 03:49:06 PM Hi all,
I want to avoid the "onSelect" event to run during the initial loading of form data. Therefore I have modified my program similary to the following thread: http://www.jeasyui.com/forum/index.php?topic=6088.0 Here is the link to my program: http://195.144.40.170/jeasyui/QQQ/index.html As you can see in the web console, the "onLoadSuccess" event is executed before the "onSelect" event. Therefore when the "onSelect" event is executed, the value of the variable "flag" is true (and not false as expected). Any help to solve this problem is appreciated. Regards. Miche Title: Re: Avoid the "onSelect" event to run during the initial loading of form data Post by: stworthy on December 26, 2016, 02:07:26 AM You called:
Code: $('#fm').form('load',{ The 'url' property is set to the combobox to retrieved data from remote server, so the combobox data is loaded later and the 'onSelect' event fires after the 'onLoadSuccess' event. Title: Re: Avoid the "onSelect" event to run during the initial loading of form data Post by: rezzonico on December 26, 2016, 03:15:20 AM Hi Stworthy ,
I understand what you mean, but I am not able to find a solution. I have tryed to create the combobox with javascript after the form load: http://195.144.40.170/jeasyui/QQQ/index1.html I also have tryed to create the combobox with javascript after the form onLoadSuccess: http://195.144.40.170/jeasyui/QQQ/index2.html None of this solution works. Can you please help me with a short example ? Thanks Strange is that if I replace the onSelect event with the onChange event it works (can this be a correct solution ?): http://195.144.40.170/jeasyui/QQQ/index3.html Regards Miche Title: Re: Avoid the "onSelect" event to run during the initial loading of form data Post by: stworthy on December 26, 2016, 06:50:40 AM The 'onChange' event fires when the value is changed. The 'onChange' event is triggered before the 'onLoadSuccess'. When the combobox loads data successfully, the 'onSelect' event fires but the 'onChange' event does not fire again because the value isn't changed.
Title: Re: Avoid the "onSelect" event to run during the initial loading of form data Post by: rezzonico on December 26, 2016, 07:05:41 AM Thanks a lot for your help.
This means that I can use the onChange event as in the following example: http://195.144.40.170/jeasyui/QQQ/index3.html correct ? But if I would use onSelect, how can I prevent the onSelect event from firing during the form load ? Thanks again for your patience. Regards Michelangelo Title: Re: Avoid the "onSelect" event to run during the initial loading of form data Post by: stworthy on December 26, 2016, 09:35:41 AM A possible solution to solve this issue is to define two functions to disable or enable the 'onSelect' event.
Code: function disableOnSelect(f){ Before calling the 'load' method, disable the 'onSelect' event. Code: disableOnSelect('#fm'); Code: <input class="easyui-combobox" name="PdL_ID" data-options=" Title: Re: Avoid the "onSelect" event to run during the initial loading of form data Post by: rezzonico on December 26, 2016, 10:37:24 AM Thanks a lot.
Since (as you wrote) the 'onChange' event is triggered before the 'onLoadSuccess', I will use the solution with the onChange event as in the following program: http://195.144.40.170/jeasyui/QQQ/index3.html Regards Miche |