Class: Wraith.CollectionView

Defined in: src/collectionview.coffee
Inherits: Wraith.ViewModel

Overview

The CollectionView provides Collection -> View binding. It handles repeated view instances, adding and removing views when models are added or removed, and updating the corresponding view when a model changes.

Instance Method Summary

Inherited Method Summary

Methods inherited from Wraith.ViewModel

#constructor, #render, #updateView, #bindModel, #unbindModel, #handleInputChange_, #handleFormSubmit_

Methods inherited from Wraith.BaseView

#constructor, #bindUIEvents, #bindUIEvent, #wrapUIEvent, #handleUIEvent, #unbindUIEvents, #unbindUIEvent, #applyViewUpdate, #updateAttribute

Methods inherited from Wraith.Base

#constructor, #bind, #unbind, #emit, #proxy

Constructor Details

- (void) constructor($el, template)

Constructor

Parameters:

  • $el (HTMLElement) The HTMLElement to bind our collection to
  • template (String) The template to use when rendering views.

Instance Method Details

- (void) createView(model)

Creates a view as a child of $el using the append method.

Parameters:

  • model (Wraith.Model) The model that this view it to use when rendering.

- (void) removeView(model)

Removes a view that was bound to a given model. Performs a lookup within the parent $el for the data-model-id=[model_id] attribute.

Parameters:

  • model (Wraith.Model) The model to do the view lookup with and remove.

- (void) updateView(model)

TODO: Break the dependency on the view bound data-model-id (which really isnt necessary)

Updates a view that is bound to the given model.

Parameters:

  • model (Wraith.Model) The model to do the view lookup with and update.