Javascript 如何在onClick事件上设置CKEDITOR对话框数据
我正在使用CKEDITOR并尝试在onClick上设置小部件数据 当我在提交时设置小部件数据时,一切正常:Javascript 如何在onClick事件上设置CKEDITOR对话框数据,javascript,ckeditor,Javascript,Ckeditor,我正在使用CKEDITOR并尝试在onClick上设置小部件数据 当我在提交时设置小部件数据时,一切正常: commit: function(widget) { widget.setData('name', this.getValue()); } 但当我尝试在onClick上执行相同操作时: onClcik: function(widget) { widget.setData('name', this.getValue()); } 我的widget对象不同,并且widget.s
commit: function(widget) {
widget.setData('name', this.getValue());
}
但当我尝试在onClick上执行相同操作时:
onClcik: function(widget) {
widget.setData('name', this.getValue());
}
我的widget
对象不同,并且widget.setData
未定义
我的问题是如何在无线电元素的onClick事件上设置小部件数据
Placholder.js
'use strict';
CKEDITOR.dialog.add('placeholder', function(editor) {
var lang = editor.lang.placeholder,
generalLabel = editor.lang.common.generalTab,
validNameRegex = /^[^\[\]<>]+$/;
return {
title: 'Insert variable from:',
minWidth: 200,
minHeight: 151,
contents: [{
id: 'initial-view',
label: 'view one',
title: generalLabel,
elements: [{
id: 'view-one',
style: 'width: 100%;',
type: 'html',
html: ''
}, {
type: 'button',
id: 'open-organizational-units',
label: 'Organizational units',
title: 'Organizational units',
className: 'dialog-btn-icon-forward',
setup: function(widget) {
this.setValue(widget.data.name);
},
onClick: function(widget) {
this.getDialog()
.selectPage('organizational-unit-view');
}
}]
}, {
id: 'organizational-unit-view',
label: 'view two',
title: generalLabel,
elements: [{
type: 'button',
id: 'back-to-main-view',
label: 'Organizational units',
title: 'Organizational units',
className: 'dialog-btn-icon-back',
setup: function(widget) {
this.setValue(widget.data.name);
},
onClick: function(widget) {
this.getDialog()
.selectPage('initial-view');
}
},
{
type: 'radio',
id: 'list-of-vars',
align: 'vertical',
style: 'color: green',
'default': '',
setup: function(widget) {
this.setValue(widget.data.name);
},
onClick: function(widget) {
widget.setData('name', this.getValue());
},
commit: function(widget) {
}
}
]
}]
};
});
“严格使用”;
CKEDITOR.dialog.add('placeholder',函数(编辑器){
var lang=editor.lang.placeholder,
generalLabel=editor.lang.common.GeneralLab,
validNameRegex=/^[^\[\]]+$/;
返回{
标题:“插入变量自:”,
最小宽度:200,
身高:151,
内容:[{
id:“初始视图”,
标签:“查看一个”,
标题:generalLabel,
要素:[{
id:'查看一个',
样式:“宽度:100%;”,
键入:“html”,
html:'
}, {
键入:“按钮”,
id:“开放式组织单位”,
标签:“组织单位”,
标题:“组织单位”,
className:“对话框btn图标前进”,
设置:功能(小部件){
this.setValue(widget.data.name);
},
onClick:函数(小部件){
这个.getDialog()
.选择页面(“组织-单位-视图”);
}
}]
}, {
id:“组织单位视图”,
标签:“视图二”,
标题:generalLabel,
要素:[{
键入:“按钮”,
id:“返回主视图”,
标签:“组织单位”,
标题:“组织单位”,
className:“返回对话框btn图标”,
设置:功能(小部件){
this.setValue(widget.data.name);
},
onClick:函数(小部件){
这个.getDialog()
.选择页面(“初始视图”);
}
},
{
键入:“收音机”,
id:'变量列表',
对齐:'垂直',
风格:“颜色:绿色”,
“默认值”:“,
设置:功能(小部件){
this.setValue(widget.data.name);
},
onClick:函数(小部件){
widget.setData('name',this.getValue());
},
提交:函数(小部件){
}
}
]
}]
};
});
要使其在onClick事件上工作,只需添加
var okBtn = document.getElementsByClassName('cke_dialog_ui_button_ok');
okBtn[0].click();
像这样的onClick函数
onClick: function(widget) {
if (this.getValue()) {
var okBtn = document.getElementsByClassName('cke_dialog_ui_button_ok');
okBtn[0].click();
}
}