pon*_*ayz 4 javascript hide ckeditor
我正在CKEditor中开发一个插件,目的是根据选中哪个复选框来隐藏或显示元素。我已经定义了那些元素:
contents :
[
{
id : 'tab1',
label : 'Configuration Basique',
elements :
[
{
type : 'checkbox',
id : 'check',
label : 'Vers une page web',
'default' : 'unchecked',
onClick : function(){
}
},
{
type : 'text',
id : 'title',
label : 'Explanation',
}
]
},
{
id : 'tab2',
label : 'Advanced Settings',
elements :
[
{
type : 'text',
id : 'id',
label : 'Id'
}
]
}
],
Run Code Online (Sandbox Code Playgroud)
所以现在我想做的是不隐藏不禁用带有标签的文本输入,仅在选中此框时打印它。所以我看到我应该使用这样的东西:
onLoad : function(){
this.getContentElement('tab1','title').disable();
},
Run Code Online (Sandbox Code Playgroud)
但问题是我不想禁用它,我想隐藏然后在用户选中该框时将其打印出来(这就是为什么我在复选框中放置了onClick函数)。我试图使用hide()函数,但是它不起作用,而且setAttribute('style','display:none;')Tia :)
小智 5
如果您实际上要隐藏(而不是禁用)该元素,则可以使用
this.getContentElement('tab1','title').getElement().hide();
Run Code Online (Sandbox Code Playgroud)
额外的getElement()调用返回contentElement对象的乱码DOM对象,因此您可以随意调用hide()/ show()。