Class: ListView

.base. ListView

A base view for lists / collections. This view is not a subclass of the View constructor.

new ListView( [collection] [, options])

Create a new List View
Parameters:
Name Type Argument Default Description
collection Array <optional>
[] The Collection of models to create the List View from
options Object <optional>
{} An options object
Properties
Name Type Argument Default Description
view function <optional>
View A View constructor to use for each item in the list

Extends

Methods


clear()

Clears the container element of any HTML and removes all listeners from this View, without removing the container element from the DOM
Inherited From:
Returns:
Returns the view object
Type
Object

emit(event [, args])

Triggers the callbacks for a given event. Subsequent arguments will be passed to the event callbacks.
Parameters:
Name Type Argument Description
event String The event name to trigger
args Any <optional>
<repeatable>
Additional arguments to pass to the event callback
Inherited From:
Returns:
Returns a Promise that resolves when all callbacks are complete
Type
Object

off( [event] [, callback])

Unsubscribe from one or more events on this object
Parameters:
Name Type Argument Description
event String <optional>
The event to remove. If none is specified, all events will be removed.
callback function <optional>
The callback to remove. If none is specified, all callbacks for the specified event will be removed.
Inherited From:
Returns:
Returns the Emitter object
Type
Object

on(event, callback)

Subscribe to an event on this object, by binding a callback function to the name of the event. Callbacks may be Promises or regular functions.
Parameters:
Name Type Description
event String | Object The name of the event to subscribe to. May also be an object mapping event names to callback functions
callback function The callback function to invoke whenever the specified event is fired
Inherited From:
Returns:
Returns the emitter object
Type
Object

once(event, callback)

Subscribe to an event on this object for one time only. After the event is triggered, the callback will be removed. Callbacks may be Promises or regular functions.
Parameters:
Name Type Description
event String The name of the event to subscribe to
callback function The callback function to invoke when the event is fired
Inherited From:
Returns:
Returns the emitter object
Type
Object

remove()

Removes all listeners from this View, and removes its container element from the DOM
Inherited From:
Returns:
Returns the view object
Type
Object

render( [options])

Inserts this view into the DOM, within the specified container. You will often want to overwrite this function on the subclass.
Parameters:
Name Type Argument Default Description
options Object <optional>
{} An options object
Properties
Name Type Argument Default Description
container Object | String <optional>
A container element to render the view in. May be either a DOM selector string or a DOM Node. If this option was already provided in the view's `container` option, this argument may be omitted.
position String <optional>
'end' The position to render this view at within its container. Possible value are `start` (inserts the view as the first element in the container), `end` (inserts the view as the last element in the container), and `replace` (clears all child nodes from the container before inserting this view). If this option was already provided in the view's `position` option, this argument may be omitted.
Inherited From:
Returns:
Returns this view object
Type
Object

template()

Compiles the List View template using the Collection data
Overrides:
Returns:
Returns a UL element containing the collection of views
Type
Object