Apply model defaults also on nested levels
[MAILPOET-1450]
This commit is contained in:
@ -2,6 +2,7 @@ import App from 'newsletter_editor/App';
|
|||||||
import Marionette from 'backbone.marionette';
|
import Marionette from 'backbone.marionette';
|
||||||
import SuperModel from 'backbone.supermodel';
|
import SuperModel from 'backbone.supermodel';
|
||||||
import _ from 'underscore'; // eslint-disable-line func-names
|
import _ from 'underscore'; // eslint-disable-line func-names
|
||||||
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
var Module = {};
|
var Module = {};
|
||||||
|
|
||||||
@ -42,7 +43,9 @@ Module.StylesModel = SuperModel.extend({
|
|||||||
backgroundColor: '#cccccc',
|
backgroundColor: '#cccccc',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
initialize: function () { // eslint-disable-line func-names
|
initialize: function (data) { // eslint-disable-line func-names
|
||||||
|
// apply model defaults recursively (not only on top level)
|
||||||
|
this.set(jQuery.extend(true, {}, this.defaults, data));
|
||||||
this.on('change', function () { App.getChannel().trigger('autoSave'); }); // eslint-disable-line func-names
|
this.on('change', function () { App.getChannel().trigger('autoSave'); }); // eslint-disable-line func-names
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user