代码之家  ›  专栏  ›  技术社区  ›  Gazillion

访问ckeditor对话框HTML元素

  •  6
  • Gazillion  · 技术社区  · 14 年前

    我很难弄清楚我必须做些什么才能访问我正在修改的插件中Keckeditor中的某些UI元素。

    从本质上讲,我是在向他们的链接对话框添加内部链接,在该对话框中,我将链接拆分为部分和出版物。当用户从“选择”下拉列表中选择一个节时,该节中的发布将填充在另一个下拉列表中。

    正在从插件文件夹中的link.js文件修改以下代码。我删掉了所有不必要的部分,忽略了我认为相关的内容。正如您在下面的代码中看到的,我正在定义一个select下拉列表,其ID为“section”,后跟“item”下拉列表。如何访问“item”下拉列表,以便在节下拉列表的onchange函数中填充它?

    如果我在运行时对ID标签中填充的ID进行硬编码,那么我就可以计算出所有的Ajax代码并进行工作,但是这会从编辑器变为编辑器,因此我不能依赖硬编码的值。

    {
     type :  'vbox',
     id : 'internalOptions',
     children :
     [
      {
       id : 'section',
       type : 'select',
       items :
       [
       ],
       setup : function( data )
       {
        //populate sections here
       },
       onChange : function (data)
       {
        //populate items here
       },
      },
      {
       id : 'item',
       type : 'select',
       items :
       [
       ],
       setup : function( data )
       {
       },
      }
    
     ]
    }
    

    编辑: 我的问题是,卷票人会改变每一个身份证,所以他们是不合格的。尽管我将下拉列表命名为“section”,但它调用的是176_节,但它并不总是相同的int,因此我需要弄清楚在设置阶段如何获取它。

    5 回复  |  直到 12 年前
        1
  •  5
  •   AlfonsoML    14 年前
        2
  •  3
  •   Andy Ford    14 年前

    {
        id : 'txtCredit', /* not CSS ID attribute! */
        type : 'text',
        label : 'Credit',
        className : 'imageCredit',
    
        elemId : null, /* to store a reference to ckeditor's automagically generated id */
    
        setup : function() {
    
            // get the id that ckeditor generated for this element and store as an object property
            this.elemId = this.getInputElement().getAttribute('id');
    
            // now we can reference the element by the id we stored above. Hacky? Yeah probably
            var inputElem = document.getElementById(this.elemId);
    
        }
    }
    
        3
  •  1
  •   Erik Melkersson    12 年前

    getContentElement

    ...
    contents : [
      {
        id : 'info',
        label : 'blabla',
        elements :
          ...
    

    var dialog = this.getDialog();
    var sectionElement = dialog.getContentElement( 'info', 'section' );
    

        4
  •  0
  •   Community CDub    8 年前

    #176_section section

    $('select[id*="_section"]')
    

    http://api.jquery.com/attribute-contains-selector/

    var selects = document.getElementsByTagName("select");
    for (var i = 0; i < selects.length; i++) {
        if(selects[i].id.indexOf("_section")) {
            // Your select box is here.  Do something with it.
        }
    }  
    

    Getting elements by a partial id string in javascript

        5
  •  0
  •   simon    14 年前

        CKEDITOR.dom.element = function( element, ownerDocument )
        {
            if ( typeof element == 'string' )
            element = ( ownerDocument ? ownerDocument.$ : document ).createElement(element );
        this.real_dom_element = element;
        // Call the base constructor (we must not call CKEDITOR.dom.node).
        CKEDITOR.dom.domObject.call( this, element );
    };
    

    onLoad : function()
    {
       $(this.getElement().blicsm_element).attr("myID", "link_url");
    }
    

    $('div[myID="link_url"]').find("input");