Skip to content

Instantly share code, notes, and snippets.

@goldalworming
Created October 5, 2015 07:33
Show Gist options
  • Save goldalworming/4435e59f451dc56ef7a4 to your computer and use it in GitHub Desktop.
Save goldalworming/4435e59f451dc56ef7a4 to your computer and use it in GitHub Desktop.
// Login API
var auth = riot.observable()
auth.login = function(params) {
$.get('/api', params, function(json) {
auth.trigger('login', json)
})
}
<!-- login view -->
<login>
<form onsubmit="{ login }">
<input name="username" type="text" placeholder="username">
<input name="password" type="password" placeholder="password">
</form>
login() {
opts.login({
username: this.username.value,
password: this.password.value
})
}
// any tag on the system can listen to login event
opts.on('login', function() {
$(body).addClass('logged')
})
</login>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment