View Full Version : Javascript Event Type Order

06-14-2008, 04:45 AM
In an ajax chat application I'm writing, a user clicks a button to create a simple text input element. This element has a 'blur' event listener attached to it, so that when the user is finished the content is automatically submitted. I'd like to give my users the ability to click the button that created the text input element to now remove that text input element without submitting it. I added a click event listener to the button that removes the text input element.

Unfortunately, the content is still submitted. I guess, when the user clicks the button, the blur listener is being executed before the click one. Is there a set order of which event types' listeners are executed? I'm not asking about capturing or bubbling. In this case, the events have different event types.

Thanks in advance,

06-14-2008, 03:53 PM
I was able to solve my problem by putting a "mousedown" event listener on the button, which is apparently run before the blur listener. If anyone has some knowledge of the underlying mechanics, please share.