Browse Source

Add `remove` listener on panel items. Fixes #1081

pull/1130/head
Artur Arseniev 8 years ago
parent
commit
cebce2e377
  1. 10
      src/panels/view/PanelView.js
  2. 11
      src/panels/view/PanelsView.js

10
src/panels/view/PanelView.js

@ -4,14 +4,16 @@ var ButtonsView = require('./ButtonsView');
module.exports = Backbone.View.extend({
initialize(o) {
const config = o.config || {};
const model = this.model;
this.config = config;
this.pfx = config.stylePrefix || '';
this.ppfx = config.pStylePrefix || '';
this.buttons = this.model.get('buttons');
this.buttons = model.get('buttons');
this.className = this.pfx + 'panel';
this.id = this.pfx + this.model.get('id');
this.listenTo(this.model, 'change:appendContent', this.appendContent);
this.listenTo(this.model, 'change:content', this.updateContent);
this.id = this.pfx + model.get('id');
this.listenTo(model, 'change:appendContent', this.appendContent);
this.listenTo(model, 'change:content', this.updateContent);
model.view = this;
},
/**

11
src/panels/view/PanelsView.js

@ -6,11 +6,18 @@ module.exports = Backbone.View.extend({
this.opt = o || {};
this.config = this.opt.config || {};
this.pfx = this.config.stylePrefix || '';
this.listenTo(this.collection, 'add', this.addTo);
this.listenTo(this.collection, 'reset', this.render);
const items = this.collection;
this.listenTo(items, 'add', this.addTo);
this.listenTo(items, 'reset', this.render);
this.listenTo(items, 'remove', this.onRemove);
this.className = this.pfx + 'panels';
},
onRemove(model) {
const view = model.view;
view && view.remove();
},
/**
* Add to collection
* @param Object Model

Loading…
Cancel
Save