-
Notifications
You must be signed in to change notification settings - Fork 121
/
login.js
36 lines (30 loc) · 876 Bytes
/
login.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
define(['SocialNetView', 'text!templates/login.html'], function(SocialNetView, loginTemplate) {
var loginView = SocialNetView.extend({
requireLogin: false,
el: $('#content'),
events: {
"submit form": "login"
},
initialize: function(options) {
this.socketEvents = options.socketEvents;
},
login: function() {
var socketEvents = this.socketEvents;
$.post('/login',
this.$('form').serialize(), function(data) {
socketEvents.trigger('app:loggedin', data);
window.location.hash = 'index';
}).error(function(){
$("#error").text('Unable to login.');
$("#error").slideDown();
});
return false;
},
render: function() {
this.$el.html(loginTemplate);
$("#error").hide();
$("input[name=email]").focus();
}
});
return loginView;
});