Using Backbone.js, I have a form as follows:
<form id="searchBar">
<input type="search" name="search" id="searchBox" value=""/>
<input type="text" name="location" id="location" value="City, ST"/>
</form>
And, a view to process said form as follows:
window.FindPlaceView = Backbone.View.extend({
/*code here*/
events: {
"submit form#searchBar" : "processClick"
},
processClick: function(e) {
e.preventDefault();
console.log("Submitted");
/*form processing code here*/
}
});
If I remove the second input field in the form, the form will submit on enter just fine. As soon as I add that second input back into the form, no dice. The binding is seemingly lost at that point.
Is there any reason why having two fields in a form would throw a loop on the submit event binding? This seems like such a stupid issue, I'm banging my head against the wall on it.
I've tried making the input a different type, stripping all the attributes out of it, everything. Even if I put an empty <input></input>
in here, it breaks.
(I should note, I don't have a submit button here, just trying to submit on enter)
Ideas?
Thanks.