oshyso
oshyso

Reputation: 11

Is it possible to set my own id to CKEditor?

CKEditor automatically generates an id like 'cke_xxx'.
Is it possible to set my own id to CKEditor instance?

Upvotes: 1

Views: 1356

Answers (1)

sean6bucks
sean6bucks

Reputation: 493

Ckeditor will create the instance name based on the DOM element it was related to ( usually id attribute ), so you can customize the instance name based on that.

If you are more referring to changing the id of the actual DOM element that CKEditor creates, I don't think there is a way to set it on creation, but you can always update it after creation with something like

var editor = CKEDITOR.instances[*instace-name*];
document.getElementById( 'cke_' + editor.element.$.id ).id = newValue

However I'm not sure if this is the best practice because it may effect built in ckeditor methods that look for "cke_" + id

Upvotes: 1

Related Questions