I'm having trouble getting backbone events working. I simply want to simulate a form submission and get an alert, but I can't seem to get there...
My markup is as follows:
<form method="post" id="userSignIn">
<label>Email</label>
<input type = "text" name = "useremail" value = "" id="userEmail">
<br />
<label>Pass</label>
<input type = "password" name = "userpass" value = "" id="userPassword">
<br /><input type = "submit" value = "Submit">
</form>
My JS
var events = _.clone(Backbone.Events);
var SigninModel = Backbone.Model.extend({
url: 'http://localhost/api/app/User.php',
});
var SignInCollection = Backbone.Collection.extend({
model: SigninModel
})
var SigninView = Backbone.View.extend({
events: {
'submit #userSignIn': 'signIn'
},
initialize: function() {
console.log('Sign in view initialized');
},
signIn: function(e) {
alert("Your username is" + $('#userSignIn #userEmail'));
e.preventDefault();
}
});
$(document).ready(function(){
var signInCollection = new SignInCollection();
new SigninView({ el: $('#userSignIn'), collection: signInCollection });
});