model-sync set
This commit is contained in:
@@ -276,7 +276,9 @@ class Model {
|
||||
* @param {{
|
||||
* silent?: boolean,
|
||||
* unset?: boolean,
|
||||
* sync?: boolean,
|
||||
* } & Object.<string, *>} [options] Options. `silent` won't trigger a `change` event.
|
||||
* `sync` can be used to emulate syncing.
|
||||
* @return {this}
|
||||
* @fires Model#change Unless `{silent: true}`.
|
||||
* @copyright Credits to Backbone.js.
|
||||
@@ -330,6 +332,14 @@ class Model {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.sync) {
|
||||
if (this.collection) {
|
||||
const modelSyncOptions = {...options, action: 'set'};
|
||||
|
||||
this.collection.trigger('model-sync', this, modelSyncOptions);
|
||||
}
|
||||
}
|
||||
|
||||
if (changing) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -2165,7 +2165,7 @@ class ListRecordView extends View {
|
||||
return;
|
||||
}
|
||||
|
||||
if (o.action === 'fetch' || o.action === 'save') {
|
||||
if (o.action === 'set' || o.action === 'fetch' || o.action === 'save') {
|
||||
model.setMultiple(m.getClonedAttributes(), o);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user