new ListView(options)
View representing a Backbone.Collection. Renders one ItemView for each model, and re-renders in response
to collection events
Parameters:
| Name | Type | Description |
|---|---|---|
options |
module:js-whatever/js/list-view.ListView~ListViewOptions |
- Source:
Extends
- Backbone.View
Methods
-
createItemView(model) → {ItemView}
-
Instantiates and renders an ItemView for the given model. Adds it to the map of model cid to ItemView.
Parameters:
Name Type Description modelThe model which needs a view
- Source:
Returns:
The new ItemView
- Type
- ItemView
-
onAdd(model, collection)
-
Callback called when a model is added to the collection
Parameters:
Name Type Description modelBackbone.Model The model added to the collection
collectionBackbone.Collection The collection
- Source:
-
onRemove(model)
-
Callback called when a model is removed from the collection
Parameters:
Name Type Description modelBackbone.Model The model that was removed from the collection
- Source:
-
onSort()
-
Callback called when the collection is sorted. This will reorder the ItemViews to reflect the new
collection order- Source:
-
remove()
-
Backbone.View remove method. Also calls each ItemView's remove method.
- Source:
-
removeView(view)
-
Remove the view and stopListening to it
Parameters:
Name Type Description viewThe view to remove
- Source:
-
removeViews()
-
Call each ItemView's remove method and reset the map of views.
- Source:
Type Definitions
-
ListViewOptions
-
- Source:
Properties:
Name Type Argument Default Description collectionBackbone.Collection The collection containing the items to render
useCollectionChangeboolean <optional>
true (Deprecated, use collectionChangeEvents instead) Whether to re-render
the associated ItemView when the collection fires a change event. This is more efficient than creating one change
listener for each model.collectionChangeEventsObject.<String, String> | Boolean <optional>
true If true, re-renders the associated ItemView
when the collection fires a change event. If an object, the keys are model attributes to listen to change events
for and the values are the names of functions to call on the associated ItemView when they occur. The callbacks
are passed the same arguments triggered by the collection. If false, no change listener is created. This is much
more efficient than creating one change listener for each model.ItemViewfunction <optional>
ListItemView The Backbone.View constructor to instantiate for each model
itemOptionsobject <optional>
{} The options to pass to the ItemView constructor in addition to the model
proxyEventsArray.<String> <optional>
[] Events to proxy from ItemViews, prefixed with 'item:'
headerHtmlString <optional>
Optional HTML to render at the top of the list.
footerHtmlString <optional>
Optional HTML to render at the bottom of the list.
maxSizenumber <optional>
If defined, caps the number of item views at the value of maxSize