Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.Site = Backbone.RelationalModel.extend({
- idAttribute: "_id",
- // These are the relations to the user model.
- relations: [{
- type: Backbone.HasMany,
- key: 'users',
- relatedModel: 'window.User'
- }],
- });
- //Site User model
- // -------------
- window.User = Backbone.RelationalModel.extend({
- });
- {
- _id: foo,
- users: [
- username: bar,
- password: fizz
- ]}
- initialize: function() {
- //basic bindings
- this.model.bind('change', this.setSave, this);
- this.model.bind('destroy', this.remove, this);
- // bindings to sub-models
- this.model.bind('add:users', this.setDetailsView, this);
- this.model.bind('remove:users', this.setSave, this);
- this.model.bind('change:users', this.setSave, this);
- initialize: function() {
- this.model.bind('change', this.render, this);
- this.model.bind('destroy', this.remove, this);
- this.model.get('users').each(function(user){
- user.bind(change,this.render,this);
- },this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement