Created
December 25, 2014 22:08
-
-
Save code-for-coffee/7207e0008e9d3a4be97b to your computer and use it in GitHub Desktop.
Backbone Enterprise Book - Ch2.4
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
/* Create namespace objects for each Backbone object type */ | |
App = new Object() || {}; | |
App.Models = new Object() || {}; | |
App.Views = new Object() || {}; | |
App.Routers = new Object() || {}; | |
App.Collections = new Object() || {}; | |
App.ActiveModels = new Object() || {}; | |
App.ActiveViews = new Object() || {}; | |
App.ActiveRouters = new Object() || {}; | |
App.ActiveCollections = new Object() || {}; | |
/* use namespace for storage */ | |
App.Models.BaseModel = Backbone.Model.extend({ | |
defaults: { | |
id: 1, | |
name: "BaseModel" | |
} | |
}); | |
App.Views.BaseView = Backbone.View.extend({ | |
el: undefined, | |
model: undefined | |
}); | |
/* use namespaces for storage */ | |
App.ActiveModels.myModel = new App.Models.BaseModel({ | |
comment: "Test!" | |
}); | |
App.ActiveViews.myView = new App.Views.BaseView({ | |
el: $('body'), | |
model: myModel | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment