I have a change event on a text input and a click event on a button. Why is the first fire the first?

I'm working on a JavaScript form (it's not actually a form - it's a Knockout interface that makes a request for another JavaScript object, but that doesn't matter) and I'm a little concerned about some kind of behavior. I'm not sure what I can rely on.

Let's say I have an input and I added a change event, either natively via onChange or via jQuery change. This change event updates the model I'm about to test and then submit to the server as part of my form submission.

I also have a button with a click event that executes the view.

If I click the button, as far as I can tell, the form element change event occurs first. But can I rely on this behavior? Is the fact that the change event triggers the first part of an accepted specification, or just an implementation detail of the browser?

I looked through the event spec ( http://www.w3.org/TR/2014/WD-DOM-Level-3-Events-20140925/ ) but couldn't find an answer to my specific question, just click, blur and focus events are processed synchronously - that is, they are added to the queue and executed in order. But I don't know if the order is consistent between user agents.

Is this behavior guaranteed by any specification?

+3


source to share





All Articles