Browse Source

Clean js scripts on component remove

pull/2031/head
Artur Arseniev 8 years ago
parent
commit
b627399ecd
  1. 7
      src/canvas/view/CanvasView.js
  2. 5
      src/dom_components/view/ComponentsView.js

7
src/canvas/view/CanvasView.js

@ -415,13 +415,14 @@ module.exports = Backbone.View.extend({
* @private * @private
*/ */
updateScript(view) { updateScript(view) {
const model = view.model;
const id = model.getId();
if (!view.scriptContainer) { if (!view.scriptContainer) {
view.scriptContainer = $('<div>'); view.scriptContainer = $(`<div id="${id}">`);
this.getJsContainer().appendChild(view.scriptContainer.get(0)); this.getJsContainer().appendChild(view.scriptContainer.get(0));
} }
const model = view.model;
const id = model.getId();
view.el.id = id; view.el.id = id;
view.scriptContainer.html(''); view.scriptContainer.html('');
// In editor, I make use of setTimeout as during the append process of elements // In editor, I make use of setTimeout as during the append process of elements

5
src/dom_components/view/ComponentsView.js

@ -18,8 +18,9 @@ module.exports = Backbone.View.extend({
const tempRemove = opts.temporary; const tempRemove = opts.temporary;
if (!view) return; if (!view) return;
view.remove.apply(view); view.remove.apply(view);
const children = view.childrenView; const { childrenView, scriptContainer } = view;
children && children.stopListening(); childrenView && childrenView.stopListening();
scriptContainer && scriptContainer.remove();
removed.components().forEach(it => this.removeChildren(it, coll, opts)); removed.components().forEach(it => this.removeChildren(it, coll, opts));
if (em && !tempRemove) { if (em && !tempRemove) {

Loading…
Cancel
Save