Browse Source

Clean previous components view

pull/1551/head
Artur Arseniev 7 years ago
parent
commit
943a341a4d
  1. 1
      src/dom_components/model/Component.js
  2. 9
      src/dom_components/view/ComponentView.js

1
src/dom_components/model/Component.js

@ -458,7 +458,6 @@ const Component = Backbone.Model.extend(Styleable).extend(
comps.parent = this;
const components = this.get('components');
const addChild = !this.opt.avoidChildren;
addChild && comps.reset();
this.set('components', comps);
addChild && comps.add(components);
this.listenTo(...toListen);

9
src/dom_components/view/ComponentView.js

@ -65,12 +65,13 @@ module.exports = Backbone.View.extend({
},
initComponents(opts = {}) {
const { model, $el } = this;
const { model, $el, childrenView } = this;
const event = 'change:components';
const components = model.get('components');
const comps = model.get('components');
if (components instanceof Components) {
$el.data('collection', components);
if (comps instanceof Components) {
$el.data('collection', comps);
childrenView && childrenView.remove();
this.stopListening(model, event, this.initComponents);
this.listenTo(model, event, this.initComponents);
!opts.avoidRender && this.renderChildren();

Loading…
Cancel
Save