model-sync set

This commit is contained in:
Yuri Kuznetsov
2025-02-19 18:04:46 +02:00
parent e29d0959c4
commit df6b5ae043
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -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;
}
+1 -1
View File
@@ -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);
}
});