Utils
Provides static utility functions.
Proxy Backbone class methods to Underscore functions, wrapping the model's attributes
object or collection's
models
array behind the scenes.
Function#apply
can be slow so we use the method's arg count, if we know it.
Example:
collection.filter(function(model) { return model.get('age') > 10 });
collection.each(this.addView);
Static Method Summary
Static Public Methods | ||
public static |
addUnderscoreMethods(Class: Class, methods: object, attribute: string) Adds Underscore methods if they exist from keys of the |
|
public static |
Method for checking whether an unknown variable is an instance of |
|
public static |
isNullOrUndef(unknown: *): boolean Method for checking whether a variable is undefined or null. |
|
public static |
urlError() Throw an error when a URL is needed, and none is supplied. |
|
public static |
wrapError(model: Model | Collection, options: object) Wrap an optional error callback with a fallback error event. |
Static Public Methods
public static addUnderscoreMethods(Class: Class, methods: object, attribute: string) source
Adds Underscore methods if they exist from keys of the methods
hash to Class
running against the variable
defined by attribute
public static isModel(unknown: *): boolean source
Method for checking whether an unknown variable is an instance of Backbone.Model
.
Params:
Name | Type | Attribute | Description |
unknown | * | Variable to test. |
public static isNullOrUndef(unknown: *): boolean source
Method for checking whether a variable is undefined or null.
Params:
Name | Type | Attribute | Description |
unknown | * | Variable to test. |
public static wrapError(model: Model | Collection, options: object) source
Wrap an optional error callback with a fallback error event.
Params:
Name | Type | Attribute | Description |
model | Model | Collection | Model or Collection target to construct and error callback against. |
|
options | object | Options hash to store error callback inside. |