Permalink
Browse files

More detailed usage example

  • Loading branch information...
1 parent 0bcd864 commit dde880d615d5ef6e03f6b967b18330b7eb9d0840 @powmedia committed Mar 22, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 README.md
View
@@ -83,30 +83,32 @@ See [schema definition](#schema-definition) for more information.
var User = Backbone.Model.extend({
schema: {
name: 'Text',
- email: { dataType: 'email', validators: ['required', validateEmail] },
+ email: { dataType: 'email', validators: ['required', 'email'] },
start: { type: 'DateTime' },
contact: { type: 'Object', subSchema: {
- name: {},
+ name: 'Text',
phone: {}
}}
address: { type: 'NestedModel', model: Address },
notes: { type: 'List' }
}
});
-
-Create the form in your Views:
+
+ var user = new User();
var formView = Backbone.View.extend({
render: function() {
var form = new Backbone.Form({
- model: users.get(userId)
+ model: user
}).render();
$(this.el).append(form.el);
return this;
}
});
+
+ $('body').append(formView.el);
Once the user is done with the form, call commit() to apply the updated values to the model. If there are validation errors they will be returned. See [validation](#validation) for more information.

0 comments on commit dde880d

Please sign in to comment.