Sequence of Events

I noticed the following issue in relation to the sequence of events firing. With just a very vanilla example that I have attached you should be able to re-create the issue. I have a combobox and a button. The button will call a javascript function. I have events attached to onselectionchange and onchange of the combobox.
The sequence of events are as follows:
(Browser is ie8 and FF3.6)

  1. Click on combox. (List Drops Down)
  2. Type in some characters in the combobox, do not select from list.
  3. Click inside combobox to close list.

Now the issue comes in when you click on the save button. It appears to be somehow tied to how quickly you click on the “SAVE” button.
A “slow” click will call the attached onchange function. However, a very rapid click causes the call to the function attached to the button to fire, and then calls the onchange.

After a “slow click” the javascript function is not called, which is what is desired.

Is there anything that I could put in my scripts or perhaps in the combo scripts to cause the onchange event to always be triggered first?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Testing</title>

 <link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxcombo.css"> 
  <script src="codebase/dhtmlxcommon.js"></script>
  <script src="codebase/dhtmlxcombo.js"></script>
 

</head>


<body>
	 <table border="0" >
	    <tr>
		<td>
    		   <select style="width:155px;" id="description" >  </select> 
		</td>
              </tr>	    
		<tr>
              <td>
    		   <input type="button" onclick="saveProcess()" value="SAVE" />

		</td>

	    </tr>
         </table>
            
    				
<script type="text/javascript">				  


  window.dhx_globalImgPath="codebase/imgs/";
  z=dhtmlXComboFromSelect("description");
  z.enableFilteringMode(false);
  z.addOption("1" ,"One");
  z.addOption("2" ,"Two");
  z.addOption("3" ,"Three");

 
  z.attachEvent("onSelectionChange",descriptionChanged);
  z.attachEvent("onChange",anyChange);
   
   
function descriptionChanged(){
alert("descriptionChanged");
}
function anyChange(){
alert("anyChange");
}
 function saveProcess(){
alert("saveProcess");
}

 
</script>
</body>
</html>

Do you use the latest combo version? We not recreated the problem with it.

Moreover, alert window is not the best way to test events. I have attached the demo.

Is there anything that I could put in my scripts or perhaps in the combo scripts to cause the onchange event to always be triggered first?

You may call confirmValue method. It’ll force value selection:

z.confirmValue();
combo.zip (21.1 KB)

I am using the latest version. Using your code, I was still able to re-create the error. Example: I made a selection, then keyed in several characters. After a quick press of the save button you can see in the log:
Key 69 was pressed
Key 69 was pressed
Key 69 was pressed
SAVE button nas been clicked
onChange event has occured
onBlur event has occured

I am not sure why this should/could occur.

Have you been able to re-create this scenario? Thanks

Yes, we have recreated the scenario. I some cases the save handler occurs before onChange. You may try to use confirmValue to solve the issue:

function saveProcess(){
z.confirmValue();
/other functionality/
}