new Selection()
wp.media.model.Selection
A selection of attachments.
- Source:
Extends
- wp.media.model.Attachments
- Backbone.Collection
Members
-
model :wp.media.model.Attachment
-
Type:
- Inherited From:
- Source:
Methods
-
<private> _changeFilteredProps(model)
-
Parameters:
Name Type Description model
Backbone.Model - Inherited From:
- Source:
-
<private> _changeOrder()
-
Sort the collection when the order attribute changes.
- Inherited From:
- Source:
-
<private> _changeOrderby(model, orderby)
-
Set the default comparator only when the `orderby` property is set.
Parameters:
Name Type Description model
Backbone.Model orderby
string - Inherited From:
- Source:
-
<private> _changeQuery(model, query)
-
If the `query` property is set to true, query the server using the `props` values, and sync the results to this collection.
Parameters:
Name Type Description model
Backbone.Model query
Boolean - Inherited From:
- Source:
-
<private> _requery()
-
If the collection is a query, create and mirror an Attachments Query collection.
- Inherited From:
- Source:
-
<private> _validateAllHandler(attachments, options)
-
Parameters:
Name Type Description attachments
wp.media.model.Attachments options
Object - Inherited From:
- Source:
Returns:
Returns itself to allow chaining. -
<private> _validateHandler(attachment, attachments, options)
-
Parameters:
Name Type Description attachment
wp.media.model.Attachments attachments
wp.media.model.Attachments options
Object - Inherited From:
- Source:
Returns:
Returns itself to allow chaining. -
add(models, options)
-
If the workflow does not support multi-select, clear out the selection before adding a new attachment to it.
Parameters:
Name Type Description models
Array options
Object - Source:
Returns:
- Type
- Array:.<wp.media.model.Attachment:>
-
hasMore()
-
Whether there are more attachments that haven't been sync'd from the server that match the collection's query. Only works if the collection is mirroring a Query Attachments collection, and forwards to its `hasMore` method. This collection class doesn't have server persistence by itself.
- Inherited From:
- Source:
Returns:
- Type
- boolean
-
initialize( [models] [, options])
-
Refresh the `single` model whenever the selection changes. Binds `single` instead of using the context argument to ensure it receives no parameters.
Parameters:
Name Type Argument Default Description models
Array <optional>
[] Array of models used to populate the collection. options
Object <optional>
{} - Overrides:
- Source:
-
mirror(The)
-
Start mirroring another attachments collection, clearing out any models already in the collection.
Parameters:
Name Type Description The
wp.media.model.Attachments attachments collection to mirror. - Inherited From:
- Source:
Returns:
Returns itself to allow chaining. -
more(options)
-
Retrieve more attachments from the server for the collection. Only works if the collection is mirroring a Query Attachments collection, and forwards to its `more` method. This collection class doesn't have server persistence by itself.
Parameters:
Name Type Description options
object - Inherited From:
- Source:
Returns:
- Type
- Promise
-
observe(The)
-
Start observing another attachments collection change events and replicate them on this collection.
Parameters:
Name Type Description The
wp.media.model.Attachments attachments collection to observe. - Inherited From:
- Source:
Returns:
Returns itself to allow chaining. -
parse(resp, xhr)
-
A custom AJAX-response parser. See trac ticket #24753
Parameters:
Name Type Description resp
Object | Array The raw response Object/Array. xhr
Object - Inherited From:
- Source:
Returns:
The array of model attributes to be added to the collection- Type
- Array
-
saveMenuOrder()
-
If this collection is sorted by `menuOrder`, recalculates and saves the menu order to the database.
- Inherited From:
- Source:
Returns:
- Type
- undefined | Promise
-
single(model)
-
Fired when toggling (clicking on) an attachment in the modal.
Parameters:
Name Type Description model
undefined | boolean | wp.media.model.Attachment - Source:
Fires:
- wp.media.model.Selection#selection:single
- wp.media.model.Selection#selection:unsingle
Returns:
- Type
- Backbone.Model
-
unmirror()
-
Stop mirroring another attachments collection.
- Inherited From:
- Source:
-
unobserve(The)
-
Stop replicating collection change events from another attachments collection.
Parameters:
Name Type Description The
wp.media.model.Attachments attachments collection to stop observing. - Inherited From:
- Source:
Returns:
Returns itself to allow chaining. -
validate(attachment, options)
-
Add or remove an attachment to the collection depending on its validity.
Parameters:
Name Type Description attachment
wp.media.model.Attachment options
Object - Inherited From:
- Source:
Returns:
Returns itself to allow chaining. -
validateAll(attachments [, options])
-
Add or remove all attachments from another collection depending on each one's validity.
Parameters:
Name Type Argument Default Description attachments
wp.media.model.Attachments options
object <optional>
{} - Inherited From:
- Source:
Fires:
- wp.media.model.Attachments#event:reset
Returns:
Returns itself to allow chaining. -
validator(attachment)
-
Checks whether an attachment is valid.
Parameters:
Name Type Description attachment
wp.media.model.Attachment - Inherited From:
- Source:
Returns:
- Type
- Boolean