-
<static> comparator(a, b, options)
-
A function to compare two attachment models in an attachments collection.
Used as the default comparator for instances of wp.media.model.Attachments
and its subclasses. @see wp.media.model.Attachments._changeOrderby().
Parameters:
Name |
Type |
Description |
a |
Backbone.Model
|
|
b |
Backbone.Model
|
|
options |
Object
|
|
- Source:
-
Returns:
-1 if the first model should come before the second,
0 if they are of the same rank and
1 if the first model should come after.
-
Type
-
Number
-
<private> _changeFilteredProps(model)
-
Parameters:
Name |
Type |
Description |
model |
Backbone.Model
|
|
- Source:
-
-
<private> _changeOrder()
-
Sort the collection when the order attribute changes.
- 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
|
|
- 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
|
|
- Source:
-
-
<private> _requery()
-
If the collection is a query, create and mirror an Attachments Query collection.
- Source:
-
-
<private> _validateAllHandler(attachments, options)
-
Parameters:
- Source:
-
Returns:
Returns itself to allow chaining.
-
Type
-
wp.media.model.Attachments
-
<private> _validateHandler(attachment, attachments, options)
-
Parameters:
- Source:
-
Returns:
Returns itself to allow chaining.
-
Type
-
wp.media.model.Attachments
-
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.
- Source:
-
Returns:
-
Type
-
boolean
-
initialize( [models] [, options])
-
Parameters:
Name |
Type |
Argument |
Default |
Description |
models |
Array
|
<optional>
|
[]
|
Array of models used to populate the collection. |
options |
Object
|
<optional>
|
{}
|
|
- Source:
-
-
mirror(The)
-
Start mirroring another attachments collection, clearing out any models already
in the collection.
Parameters:
- Source:
-
Returns:
Returns itself to allow chaining.
-
Type
-
wp.media.model.Attachments
-
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
|
|
- Source:
-
Returns:
-
Type
-
Promise
-
observe(The)
-
Start observing another attachments collection change events
and replicate them on this collection.
Parameters:
- Source:
-
Returns:
Returns itself to allow chaining.
-
Type
-
wp.media.model.Attachments
-
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
|
|
- Source:
-
Returns:
The array of model attributes to be added to the collection
-
Type
-
Array
-
-
If this collection is sorted by `menuOrder`, recalculates and saves
the menu order to the database.
- Source:
-
Returns:
-
Type
-
undefined
|
Promise
-
unmirror()
-
Stop mirroring another attachments collection.
- Source:
-
-
unobserve(The)
-
Stop replicating collection change events from another attachments collection.
Parameters:
- Source:
-
Returns:
Returns itself to allow chaining.
-
Type
-
wp.media.model.Attachments
-
validate(attachment, options)
-
Add or remove an attachment to the collection depending on its validity.
Parameters:
- Source:
-
Returns:
Returns itself to allow chaining.
-
Type
-
wp.media.model.Attachments
-
validateAll(attachments [, options])
-
Add or remove all attachments from another collection depending on each one's validity.
Parameters:
- Source:
-
Fires:
- wp.media.model.Attachments#event:reset
Returns:
Returns itself to allow chaining.
-
Type
-
wp.media.model.Attachments
-
validator(attachment)
-
Checks whether an attachment is valid.
Parameters:
- Source:
-
Returns:
-
Type
-
Boolean