Ckeditor 自定义插件 - 带有单选按钮的对话框
Ckeditor custom plugin - dialog with radio buttons
我正在尝试在 CKEditor 中构建一个自定义插件,其中单选按钮列表中的元素选择会更改所选元素的类。例:
选择BIG
将添加类big
、 MEDIUM
=> med
和 SMALL
=> sml
。
我在必须检索所选元素的值的部分被阻止。其他事情进展顺利,我设法在下面的代码中将类"MYCLASS"应用于最接近的li
标签。
问:如何在 CKeditor 的 dialog
元素中获取所选单选按钮的值?
这是代码:
CKEDITOR.dialog.add( 'MyDialog', function ( editor ) {
function getListElement( editor, listTag ) {
var range;
try {
range = editor.getSelection().getRanges()[ 0 ];
} catch ( e ) {
return null;
}
range.shrink( CKEDITOR.SHRINK_TEXT );
return editor.elementPath( range.getCommonAncestor() ).contains( listTag, 1 );
}
return {
title: 'Size of the element',
minWidth: 400,
minHeight: 200,
contents: [
{
id: 'tab-basic',
label: 'Size of an element',
elements: [
{
type: 'radio',
id: 'bullet-size',
label: 'Size of the bullets',
items: [ [ 'BIG', 'big' ], [ 'MEDIUM', 'mdm' ],[ 'SMALL', 'sml' ] ],
style: 'color: green',
'default': 'big',
},
]
},
],
onOk: function() {
var editor = this.getParentEditor(),
element = getListElement( editor, 'ul' ),
dialog = this,
config = editor.config,
lang = editor.lang,
style = new CKEDITOR.style(config.coreStyles_alpha);
editor.attachStyleStateChange(style, function(state) {
!editor.readOnly;
});
count = element.getChildren().count();
for(k=1; k <= count; k++){
element.getChild(k-1).setAttribute('class', 'MyClass');
}
}
}
});
这是获取值的方法。在onOk
功能内部:
var my_variable = this.getVazlueOf(Id_of_you_tab, id_of_the_radio_list);
相关文章:
- 复选框/单选按钮-添加所选项目的总价
- 谷歌应用程序脚本示例-如何更改单选按钮的列表框相关值
- 单选按钮的验证(启用)&使用Jquery Optimization从复选框中选择submit按钮
- 单击单选按钮时选中所有复选框
- 将文本框/单选按钮/和下拉列表中的信息添加到dataTable
- 内联JavaScript启用/禁用点击单选按钮上的选择和文本框
- 基于单选按钮和复选框的数据表排序
- 根据文本框中键入的文本筛选单选按钮列表
- JavaScript - 如果未选中复选框,则取消选中单选按钮
- 选中的单选按钮在jQuery模式对话框中不能正常工作
- Ckeditor 自定义插件 - 带有单选按钮的对话框
- 带有使用 JQuery 的单选按钮的确认对话框
- 使用JS confrim对话框验证单选按钮
- 文本框开关,带有基于部分视图MVC 4的模式对话框上的单选按钮
- ajax调用中jquery对话框上未选中单选按钮
- 更新:jquery对话框模式单选按钮未选择ajax
- 用单选按钮单击时显示对话框
- 如何取消用户的单选按钮选择,在确认对话框后取消选择
- 如何在单选按钮onchange()事件上加载自定义对话框
- 表单,带有两个使用jquery对话框的单选按钮