Home

Class mvc.Collection

A collection of models. Extends model so it has it's own values

extends mvc.Model
Instance Method Summary
add((Array|mvc.Model|null) model, number= opt_ind, boolean= opt_silent) ⇒ boolean

accepts a model or array of models and adds them at the end unless an index to insert is given.

at(number index) ⇒ ?mvc.Model

get a model by it's index in the collection

change_()
clear(boolean= opt_silent)

remove all models from the collection

getById(string id) ⇒ ?mvc.Model

get a model by it's ID

getLength() ⇒ number

returns the number of models in the collection

getModels((function ((mvc.Model|null)): (Boolean|null)=) opt_filter) ⇒ ?Array

get all the models, optionally filter by function

modelChange(?Function fn, ?Object= opt_handler) ⇒ number

use this to bind functions to a change in any of the collections models

newModel(?Object= opt_options, boolean= opt_silent) ⇒ ?mvc.Model

add a new model with the given options. The type of model is given by the modelType of the collection

pluck((Array|null|string) key) ⇒ ?Array.<(Object.<*>|null)>

plucks an attribute from each model and returns as an array. If you pass an array of keys then the array will contain a map of each key and it's value

remove((Array|mvc.Model|null) model, boolean= opt_silent)

remove the given model from the collection

setComparator(function ((mvc.Model|null), (mvc.Model|null)): number fn, boolean= opt_silent)

function to sort models by. Function should take two models and return -1, 0 or 1. Also takes whether to fire a change event after sorting

sort(boolean= opt_silent)

tells the collection to sort it's models. This is used internally

unbind(number id) ⇒ boolean

unbind a listener by id