2016-03-15 70 views
0

我试图建立一个自定义插件在CKEditor的其中一个选择的单选按钮列表中的元素的更改类所选元素的对话框。例如:CKEDITOR定制插件 - 与单选按钮

选课BIG将添加类bigMEDIUM =>medSMALL =>sml

我阻塞在我必须检索所选元素的值的部分。 Eveything否则会罚款,我在代码托管波纹管应用类“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'); 
     } 
    } 
    } 
}); 

回答

1

这里获得价值的方式。里面的onOk功能:

var my_variable = this.getVazlueOf(Id_of_you_tab, id_of_the_radio_list);