如何将占位符属性添加到CKEditor的实例?

问题描述:

现在,使用 Alfonso的插件,我可以在config.js中添加占位符属性。但是,因为我正在添加到config.js中,这意味着所有实例都将具有相同的占位符文本,对吧?

Right now, using Alfonso's plugin, I'm able to add the placeholder attribute in config.js. However, since I'm adding into config.js, that means all instances will have the same placeholder text, right?

好吧,我不希望我的ckeditor的所有实例都有相同的占位符文本,因为我也注意到他也说:

Well, I don't want all instances of my ckeditor to have the same placeholder text because I also noticed he also said :


该值可以在配置中设置,也可以作为替换元素的属性设置

我认为这意味着我们可以将输入内容...作为ckeditor1的占位符文本和Blabla ...作为ckeditor2的占位符文本。我怎么做?或者那不是他的意思?

I figured this means that we can put "Type something..." as placeholder text for ckeditor1 and "Blabla..." as placeholder text for ckeditor2. How do I do that? Or that's not what he meant?

我尝试了几种方式,包括

I have tried several ways including

    var ckeditor = CKEDITOR.replace('ckeditor1');
    ckeditor.placeholder = 'Type sometheing....';

    var config = [];
    config['placeholder'] = 'some value'; //or config = [{placeholder:'some value'}]
    CKEDITOR.replace("myeditor" , config );

在该特定页面内但无济于事......我也清除了我的缓存。

inside that particular page but to no avail... I've also cleared my cache.

根据我的意思:

<textarea name="editor" placeholder="Type here..."></textarea>

关于你的其他方法,配置是一个对象,所以这应该有效:

with regards to your other approaches, the configuration is an object, so this should work:

var config = {};
config.placeholder = 'some value'; 
CKEDITOR.replace("myeditor" , config );