I have events for 'submit' on a form. In IE8, if I submit the form without entering any information, just simply click the submit button, it posts the form and it's never caught or handled by the defined event in Backbone. However, if I simply click on an input field, then hit submit the event is handled.
The backbone event is setup like this:
events: {
'submit #form': 'submitForm',
},
submitForm: function(e){
e.preventDefault();
}
Any ideas why this would be?
Update: Here's an example of form:
<div id="form">
<form action="/action" method="post">
<input type="text" name="name" />
<button type="submit" value="Submit"></button>
</form>
</div>
It's literally only in IE8 and ONLY if you don't first click an element within the form, before submitting. The event is triggered in FF, Chrome, IE9+ without a problem. But only in IE8, if you just click submit, without doing anything else, the event doesn't get triggered.
Some events can't be delegated using this method. 'focus' and 'blur' don't work, and in IE8 and lower 'change', 'submit' and 'reset' don't work either. It's actually in the annotated source of Backbone but for some reason not in the documentation.
JQuery's documentation actually states that the method that Backbone uses ($.delegate) is now superseded by $.on which is able to handle those kinds of events.
So your options are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With