Created
October 5, 2015 07:33
-
-
Save goldalworming/4435e59f451dc56ef7a4 to your computer and use it in GitHub Desktop.
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
// 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