如何将占位符属性添加到CKEditor的实例? [英] How do I add a placeholder attribute to an instance of CKEditor?

查看:117
本文介绍了如何将占位符属性添加到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 );

这篇关于如何将占位符属性添加到CKEditor的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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