Class: ListView

js-whatever/js/list-view. ListView

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
model

The 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
model Backbone.Model

The model added to the collection

collection Backbone.Collection

The collection

Source:

onRemove(model)

Callback called when a model is removed from the collection

Parameters:
Name Type Description
model Backbone.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
view

The view to remove

Source:

removeViews()

Call each ItemView's remove method and reset the map of views.

Source:

Type Definitions

ListViewOptions

Properties:
Name Type Argument Default Description
collection Backbone.Collection

The collection containing the items to render

useCollectionChange boolean <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.

collectionChangeEvents Object.<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.

ItemView function <optional>
ListItemView

The Backbone.View constructor to instantiate for each model

itemOptions object <optional>
{}

The options to pass to the ItemView constructor in addition to the model

proxyEvents Array.<String> <optional>
[]

Events to proxy from ItemViews, prefixed with 'item:'

headerHtml String <optional>

Optional HTML to render at the top of the list.

footerHtml String <optional>

Optional HTML to render at the bottom of the list.

maxSize number <optional>

If defined, caps the number of item views at the value of maxSize

Source:
Copyright 2013-2018 Micro Focus International plc. Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
Documentation generated by JSDoc 3.4.3 on Thu Jun 21st 18:04 2018 using the DocStrap template.