是否可以将自己的ID设置为CKEditor? [英] Is it possible to set my own id to CKEditor?

查看:59
本文介绍了是否可以将自己的ID设置为CKEditor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CKEditor 自动生成一个ID,例如 cke_xxx。

是否可以将自己的ID设置为CKEditor实例?

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

推荐答案

Ckeditor将创建实例基于与之相关的DOM元素的名称(通常是id属性),因此您可以基于该名称自定义实例名称。

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.

如果您更多是指更改CKEditor创建的实际DOM元素的id,我不认为有一种在创建时进行设置的方法,但是您始终可以在创建后使用类似的东西对其进行更新

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

但是我不确定这是否是最佳实践,因为它可能会影响在ckeditor方法中构建的查找 cke _ + id的方法

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

这篇关于是否可以将自己的ID设置为CKEditor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆