Skip to content

Instantly share code, notes, and snippets.

@willbailey
Created April 2, 2009 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save willbailey/89334 to your computer and use it in GitHub Desktop.
Save willbailey/89334 to your computer and use it in GitHub Desktop.
View Constructor:
this.configure(options);
this._reset();
this.render();
Base View
.el - conventional root element reference for every view
.toElement - returns this.el
.childViews - Array of child views
<optional> cleanup - calls cleanup on all child views
.destroy - el remove and cleanup
._reset - clears dom beneath the root node and calls cleanup on all childViews
._tagName property (optional) defaults to div
._klassName property (optional) added as underscored css class
DOM Utilities
.setMode - sets css class and js mode on a view...allows mode grouping
.attachCallbacks - create bound callbacks via css selectors
-- no more .get in zenview --
- template should always be inserted into the views root element
Configurable
.configure - takes default_options and extends it with passed in options
- if a setter exists with the option key name call it with the value as arguments
Bindable - provides conventional hooks for model observation
.on[Property]Changed
.onModelChanged
.onModelAdded
.onModelRemoved
.onModelUpdated
.setModel - conventional way to set a model binding for a view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment