Is it possible to set my own id to CKEditor?

前提是你 提交于 2019-12-24 08:28:43

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/42557746/is-it-possible-to-set-my-own-id-to-ckeditor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!