Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (33 sloc) 0.941 kB
<style>
body {
padding: 50px;
font: 14px Helvetica, Arial;
}
label {
display: block;
clear: both;
}
</style>
<h1>Autosubmit</h1>
<p>Auto-submit a form with XHR via its action and method:</p>
<div class="login">
<form action="/user" method="post" autosubmit>
<input type="text" name="name" placeholder="Username" />
<input type="password" name="pass" placeholder="Password" />
<input type="submit" value="Login" />
</form>
</div>
<script src="./reactive.js"></script>
<script>
var reactive = require('reactive');
var view = reactive(document.querySelector('.login'));
// custom binding available to this view only
view.bind('autosubmit', function(el){
el.onsubmit = function(e){
e.preventDefault();
var path = el.getAttribute('action');
var method = el.getAttribute('method').toUpperCase();
console.log('submit to %s %s', method, path);
};
});
</script>
Jump to Line
Something went wrong with that request. Please try again.