Browse Source

Up clearItems

canvas-spot
Artur Arseniev 3 years ago
parent
commit
60b810922d
  1. 4
      src/abstract/ModuleDomainViews.ts
  2. 8
      src/canvas/view/FramesView.ts

4
src/abstract/ModuleDomainViews.ts

@ -43,7 +43,7 @@ export default abstract class ModuleDomainViews<
* @private * @private
* */ * */
private add(model: ModuleModel, fragment?: DocumentFragment) { private add(model: ModuleModel, fragment?: DocumentFragment) {
const { reuseView, viewCollection, itemsView = {} } = this; const { reuseView, viewCollection } = this;
var frag = fragment || null; var frag = fragment || null;
var typeField = model.get(this.itemType); var typeField = model.get(this.itemType);
let view; let view;
@ -64,7 +64,7 @@ export default abstract class ModuleDomainViews<
} }
render() { render() {
var frag = document.createDocumentFragment(); const frag = document.createDocumentFragment();
this.clearItems(); this.clearItems();
this.$el.empty(); this.$el.empty();

8
src/canvas/view/FramesView.ts

@ -10,7 +10,6 @@ export default class FramesView extends ModuleDomainViews<Frames, FrameWrapView>
constructor(opts = {}, config: any) { constructor(opts = {}, config: any) {
super(opts, true); super(opts, true);
//console.log(this.collection)
this.listenTo(this.collection, 'reset', this.render); this.listenTo(this.collection, 'reset', this.render);
this.canvasView = config.canvasView; this.canvasView = config.canvasView;
this._module = config.module; this._module = config.module;
@ -24,6 +23,13 @@ export default class FramesView extends ModuleDomainViews<Frames, FrameWrapView>
const { $el, ppfx } = this; const { $el, ppfx } = this;
$el.attr({ class: `${ppfx}frames` }); $el.attr({ class: `${ppfx}frames` });
} }
clearItems() {
const items = this.viewCollection || [];
items.forEach(item => item.remove());
this.viewCollection = [];
}
protected renderView(item: any, type: string) { protected renderView(item: any, type: string) {
return new FrameWrapView(item, this.canvasView); return new FrameWrapView(item, this.canvasView);
} }

Loading…
Cancel
Save