destroy Method

Description

Destroys the currently instantiated editor instance and releases all of its resources.

Note: the destroy method destroys the DOM element that contains the editor. In the first example below, this is the element with id 'editor-node'.

To create a new editor you will need to recreate the dom element. See example 2 below.

Syntax

.destroy()

Example 1

editor = new window.__editor(undefined, document.getElementById('editor-node'));

editor.startup({
	serviceUrl: 'http://www.yourdomain.com/esd',
	licenseId: '===License ID===',
	...
});

// This destroys the editor and the containing element (the element with id editor-node).
editor.destroy();

// Editor can now be safely recreated as needed.
		

Example 2

var editor = undefined;
var node = document.getElementById('editor-node')

function createEditor() {
	editor = new window.__editor(undefined, node);

	editor.startup({
		serviceUrl: 'http://www.yourdomain.com/esd',
		licenseId: '===License ID===',
		...
	});
}

function recreateEditor() {
	var parent = node.parentElement;
	var nextSibling = node.nextElementSibling;

	node = document.createElement("div");
	node.id = 'editorNode';
	node.setAttribute('style', 'width:100%;height:100%');
	parent.insertBefore(node, nextSibling);
	createEditor();
}

createEditor();
editor.destroy();
recreateEditor();

// Editor can now be safely recreated as needed.