Alistair Lee
Alistair Lee

Reputation: 81

How to destroy CKEditor instance using variable for its name

this is how I destroy CKEditor instance:

CKEDITOR.instances.Divname.destroy();

with Divname being id of the div.

but, how to destroy instance, if I use variable like this:

var x = "Divname";
CKEDITOR.instances.x.destroy();

It'll give me x is undefined error.

running example: http://jsfiddle.net/DBbYm/1/ please enable the instance (to attach editor), and then disable the instance (to destroy), and you'll get the error.

Any advice to solve this?

Upvotes: 1

Views: 2313

Answers (1)

Simon Edström
Simon Edström

Reputation: 6619

In JS you could call members like this

var x = "Divname";
CKEDITOR.instances[x].destroy();

Upvotes: 8

Related Questions