-
Notifications
You must be signed in to change notification settings - Fork 0
Views
Views are extended versions of Backbone Views. All views should subclass CocoView and its subclasses in /app/views/kinds and generally use their features. These include:
Described in the wiki article.
Larger views can (and should!) be broken down into many constituent parts, and in order to tie them together:
- In the parent view template, have the id of the child view where it will be inserted.
- In the parent view initialization logic, either in afterRender or after whatever resources are loaded, use @addSubview for a CocoView instance.
Views which have no parent should subclass RootView, and any subviews can simply subclass CocoView directly.
Using addSubview is important to do because it ties in with the next feature:
When a view is navigated away from, its destroy function is called, which tears down those shortcuts, subscriptions and events as best it can. It also recursively tears down any subviews that were inserted through insertSubview.
Modals are views too, and by using openModalView in CocoView they can be handled uniformly. Modals should subclass ModalView.
If you're building client views, it's recommended you look through the files in /app/views/kinds to familiarize yourself with the common tools, and how things are generally done.