Skip to content

Instantly share code, notes, and snippets.

@josepjaume
Created January 5, 2012 17:13
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 josepjaume/1566178 to your computer and use it in GitHub Desktop.
Save josepjaume/1566178 to your computer and use it in GitHub Desktop.
backbone-form-builder idea
var model = new Backbone.Model.extend();
// The form would bind to the model's "error" event.
// Any error retrieved from the JSON response or js
// validations would be captured.
//
// Sending the form would simply call the model's
// 'save' function with its serialized attributes
// and therefore would either render the errors or
// fire up the 'success' callback.
//
form = new FormBuilder({
model: model,
fields: [['email', 'string'], ['biography', 'text']],
success: function(){
Backbone.History.navigate('/models/' + this.model.get('id'));
}
);
// This would render the form and all its fields
$("#form").append(form.render().el);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment