Created
June 29, 2011 22:40
-
-
Save mrjjwright/1055184 to your computer and use it in GitHub Desktop.
Backbone SignIn View that uses dnode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modalContent = """ | |
<li> | |
<input id="email" placeholder="Email" type="text"></input> | |
</li> | |
<li> | |
<input id="password" placeholder="Password" type="password"></input> | |
</li> | |
""" | |
class App.SigninView extends Backbone.View | |
events: | |
'click #confirm_btn': 'signin' | |
initialize: -> | |
_.bindAll(this, 'signin', 'render') | |
App.subscribe 'NotAuthenticated', @render | |
render: -> | |
@el = modalContent | |
return @ | |
signin: -> | |
App.db.signin @el.$('#email').val(), @el.$('#password').val(), (err, user) => | |
if err? | |
return @el.$('.flash').html(err.message).show() | |
# Save the user in cache | |
App.cache.set "user", user | |
# Alert the app that the user is authenticated | |
App.publish "UserWasAuthenticated", user | |
# Close the modal | |
@el.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment