Class: Wraith.BaseView
Defined in: | src/baseview.coffee |
Inherits: | Wraith.Base |
Overview
The core Wraith View responsible for rendering a single instance of a view. It will bind to a models update event and re-render each time it changes. Additionally it will handle setting classes up based on the data-class directive, and other bindings that might be required in the future.
Direct Known Subclasses
Wraith.Controller, Wraith.ViewModel
Instance Method Summary
- - (void) constructor($el) Constructor Constructor
- - (void) bindUIEvents($view) Bound Iterates over a view and its children looking for the data-events attribute which should be a comma separated list of events.
- - (void) bindUIEvent($view, event) Bound Binds to a UI event on a given view.
- - (void) wrapUIEvent(cb) Bound Used as a wrapper for handling UI events and maintaining the proper context.
- - (void) handleUIEvent(e, cb) Bound Handles a UI event on the view level.
- - (void) unbindUIEvents($view) Bound Unbinds a given view and its childrens UI events.
- - (void) unbindUIEvent($view, event) Bound Unbinds a given view from the given set of events.
- - (void) applyViewUpdate($old, $new) Bound Crawls the old nodes and new nodes, compares their contents and attributes, and updates the old node accordingly.
- - (void) updateAttribute(name, $old, $new) Updates a given attribute on $old to the current value on $new.
Inherited Method Summary
Methods inherited from Wraith.Base
#constructor, #bind, #unbind, #emit, #proxy
Constructor Details
- (void) constructor($el)
Constructor
Instance Method Details
- (void) bindUIEvents($view) (bound)
Iterates over a view and its children looking for the data-events attribute which should be a comma separated list of events. The scheme is defined by #bindUIEvent
- (void) bindUIEvent($view, event) (bound)
Binds to a UI event on a given view. Relies on the data-events attribute to be a space or comma delimited list of events. A valid event is given in the schema event:callback The event must be part of Wraith.UIEVENTS
- (void) wrapUIEvent(cb) (bound)
Used as a wrapper for handling UI events and maintaining the proper context.
- (void) handleUIEvent(e, cb) (bound)
Handles a UI event on the view level. Calls stopPropagation by default to prevent bubbling. Also will emit a uievent for the parent controller to listen to so it can invoke the proper method in the controller.
- (void) unbindUIEvents($view) (bound)
Unbinds a given view and its childrens UI events.
- (void) unbindUIEvent($view, event) (bound)
Unbinds a given view from the given set of events. Follows the same schema as Wraith.BaseView#bindUIEvent does for binding.
- (void) applyViewUpdate($old, $new) (bound)
Crawls the old nodes and new nodes, compares their contents and attributes, and updates the old node accordingly. This prevents the entire view from re-rendering each time data changes.
- (void) updateAttribute(name, $old, $new)
Updates a given attribute on $old to the current value on $new. Used to update values on a DOM element without having to rewrite the entire DOM structure (children etc).