Fix container to track child changes for initial newsletter
This commit is contained in:
@@ -18,6 +18,21 @@ define([
|
|||||||
base = BaseBlock,
|
base = BaseBlock,
|
||||||
BlockCollection;
|
BlockCollection;
|
||||||
|
|
||||||
|
BlockCollection = Backbone.Collection.extend({
|
||||||
|
model: base.BlockModel,
|
||||||
|
initialize: function() {
|
||||||
|
this.on('add change remove', function() { App.getChannel().trigger('autoSave'); });
|
||||||
|
},
|
||||||
|
parse: function(response) {
|
||||||
|
var self = this;
|
||||||
|
return _.map(response, function(block) {
|
||||||
|
var Type = App.getBlockTypeModel(block.type);
|
||||||
|
// TODO: If type has no registered model, use a backup one
|
||||||
|
return new Type(block, {parse: true});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
Module.ContainerBlockModel = base.BlockModel.extend({
|
Module.ContainerBlockModel = base.BlockModel.extend({
|
||||||
relations: {
|
relations: {
|
||||||
blocks: BlockCollection,
|
blocks: BlockCollection,
|
||||||
@@ -52,21 +67,6 @@ define([
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
BlockCollection = Backbone.Collection.extend({
|
|
||||||
model: base.BlockModel,
|
|
||||||
initialize: function() {
|
|
||||||
this.on('add change remove', function() { App.getChannel().trigger('autoSave'); });
|
|
||||||
},
|
|
||||||
parse: function(response) {
|
|
||||||
var self = this;
|
|
||||||
return _.map(response, function(block) {
|
|
||||||
var Type = App.getBlockTypeModel(block.type);
|
|
||||||
// TODO: If type has no registered model, use a backup one
|
|
||||||
return new Type(block, {parse: true});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Module.ContainerBlockView = Marionette.CompositeView.extend({
|
Module.ContainerBlockView = Marionette.CompositeView.extend({
|
||||||
regionClass: Marionette.Region,
|
regionClass: Marionette.Region,
|
||||||
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
|
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
|
||||||
|
Reference in New Issue
Block a user