public
Created

backbone.syphon

  • Download Gist
1.html
HTML
1 2 3 4 5 6
<script id="my-form-template" type="text/html">
<form>
<input type="text" id="foo" value="bar">
<input type="checkbox" id="chk" checked>
</form>
</script>
2.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Backbone.View.extend({
events: {
"submit form": "formSubmitted"
},
 
formSubmitted: function(e){
e.preventDefault();
 
var data = Backbone.Syphon.serialize(this);
this.model.set(data);
 
this.model.save();
},
 
render: function(){
// build the view's form, here
}
});
3.js
JavaScript
1 2 3 4
{
foo: "bar",
chk: true
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.