Class: Values

wp.customize. Values


new Values()

A collection of observable values.
Mixes In:
  • wp.customize.Events
Source:

Extends

  • wp.customize.Class

Members


defaultConstructor :object

The default constructor for items of the collection.
Type:
  • object
Source:

Methods


_change()

A helper function to propagate a 'change' event from an item to the collection itself.
Source:

add(item [, itemObject])

Add an item to the collection.
Parameters:
Name Type Argument Description
item string | wp.customize.Class The item instance to add, or the ID for the instance to add. When an ID string is supplied, then itemObject must be provided.
itemObject wp.customize.Class <optional>
The item instance when the first argument is a ID string.
Source:
Returns:
The new item's instance, or an existing instance if already added.
Type
wp.customize.Class

create(id, value)

Create a new item of the collection using the collection's default constructor and store it in the collection.
Parameters:
Name Type Description
id string The ID of the item.
value mixed Any extra arguments are passed into the item's initialize method.
Source:
Returns:
The new item's instance.
Type
mixed

each(callback, context)

Iterate over all items in the collection invoking the provided callback.
Parameters:
Name Type Description
callback function Function to invoke.
context object Object context to invoke the function with. Optional.
Source:

has(id)

Whether the collection has an item with the given ID.
Parameters:
Name Type Description
id string The ID of the item to look for.
Source:
Returns:
Type
Boolean

instance(id)

Get the instance of an item from the collection if only ID is specified. If more than one argument is supplied, all are expected to be IDs and the last to be a function callback that will be invoked when the requested items are available.
Parameters:
Name Type Description
id string ID of the item.
Source:
See:
  • {api.Values.when:}
Returns:
The item instance if only one ID was supplied. A Deferred Promise object if a callback function is supplied.
Type
mixed

remove(id)

Remove an item from the collection.
Parameters:
Name Type Description
id string The ID of the item to remove.
Source:

value(id)

Get the instance of an item.
Parameters:
Name Type Description
id string The ID of the item.
Source:
Returns:

when()

Runs a callback once all requested values exist. when( ids*, [callback] ); For example: when( id1, id2, id3, function( value1, value2, value3 ) {} );
Source:
Returns:
$.Deferred.promise();