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)
- Click on combox. (List Drops Down)
- Type in some characters in the combobox, do not select from list.
- 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>