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
*/
updateScript(view) {
const model = view.model;
const id = model.getId();
if (!view.scriptContainer) {
view.scriptContainer = $('<div>');
view.scriptContainer = $(`<div id="${id}">`);
this.getJsContainer().appendChild(view.scriptContainer.get(0));
}
const model = view.model;
const id = model.getId();
view.el.id = id;
view.scriptContainer.html('');
// 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;
if (!view) return;
view.remove.apply(view);
const children = view.childrenView;
children && children.stopListening();
const { childrenView, scriptContainer } = view;
childrenView && childrenView.stopListening();
scriptContainer && scriptContainer.remove();
removed.components().forEach(it => this.removeChildren(it, coll, opts));
if (em && !tempRemove) {

Loading…
Cancel
Save