From 5b59865a656f03f062e13827628ce38dffc9e870 Mon Sep 17 00:00:00 2001 From: Cory Forsyth Date: Thu, 16 Jul 2015 22:32:53 -0400 Subject: [PATCH] destroy editor in demo before booting a new one --- demo/demo.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index aa2c5463b..e516724e0 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -7,6 +7,8 @@ function removeChildren(element) { } } +var editor; + var selfieCard = { name: 'selfie-card', display: { @@ -214,7 +216,10 @@ var ContentKitDemo = exports.ContentKitDemo = { }; function bootEditor(element, mobiledoc) { - var editor = new ContentKit.Editor(element, { + if (editor) { + editor.destroy(); + } + editor = new ContentKit.Editor(element, { autofocus: false, mobiledoc: mobiledoc, cards: [simpleCard, cardWithEditMode, cardWithInput, selfieCard] @@ -345,7 +350,6 @@ var sampleMobiledocs = { $(function() { - var editor; var editorEl = $('#editor')[0]; var mobiledoc = sampleMobiledocs.simpleMobiledoc;