Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
Created June 29, 2011 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrjjwright/1055184 to your computer and use it in GitHub Desktop.
Save mrjjwright/1055184 to your computer and use it in GitHub Desktop.
Backbone SignIn View that uses dnode
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