diff --git a/src/canvas/model/Frame.js b/src/canvas/model/Frame.js index 98114d657..4b9db8327 100644 --- a/src/canvas/model/Frame.js +++ b/src/canvas/model/Frame.js @@ -42,6 +42,12 @@ export default Backbone.Model.extend({ this.set('styles', new CssRules(styles, modOpts)); }, + remove() { + this.view = 0; + const coll = this.collection; + return coll && coll.remove(this); + }, + getHead() { return [...this.get('head')]; }, diff --git a/src/canvas/view/FrameView.js b/src/canvas/view/FrameView.js index c955484a9..20214c800 100644 --- a/src/canvas/view/FrameView.js +++ b/src/canvas/view/FrameView.js @@ -15,7 +15,8 @@ export default Backbone.View.extend({ tagName: 'iframe', attributes: { - allowfullscreen: 'allowfullscreen' + allowfullscreen: 'allowfullscreen', + 'data-frame-el': true }, initialize(o) { @@ -137,7 +138,7 @@ export default Backbone.View.extend({ const { root, model } = this; Backbone.View.prototype.remove.apply(this, arguments); root.remove(); - model.view = 0; + model.remove(); }, startAutoscroll() { diff --git a/src/canvas/view/FrameWrapView.js b/src/canvas/view/FrameWrapView.js index 89c950fb8..9cd5c8dc7 100644 --- a/src/canvas/view/FrameWrapView.js +++ b/src/canvas/view/FrameWrapView.js @@ -14,7 +14,14 @@ export default Backbone.View.extend({ }, initialize(opts = {}, conf = {}) { - bindAll(this, 'onScroll', 'frameLoaded', 'updateOffset'); + bindAll( + this, + 'onScroll', + 'frameLoaded', + 'updateOffset', + 'remove', + 'startDrag' + ); const { model } = this; const config = { ...(opts.config || conf), @@ -135,14 +142,15 @@ export default Backbone.View.extend({ }, render() { - const { frame, $el, ppfx, cv, model } = this; + const { frame, $el, ppfx, cv, model, el } = this; + const { onRender } = model.attributes; frame.render(); $el .empty() .attr({ class: `${ppfx}frame-wrapper` }) .append( ` -