Created
January 5, 2012 17:13
-
-
Save josepjaume/1566178 to your computer and use it in GitHub Desktop.
backbone-form-builder idea
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
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