繁体   English   中英

如何从嵌套在对话框中的iframe中的ckeditor中获取所选元素

[英]How to get the selected element from ckeditor inside an iframe nested in the dialog box

我正在构建一个构建<dl>表的CKEditor 3插件。 使用iframedialog插件,我在弹出的ckeditor对话框中创建了一个IFrame。 我可以用任意数量的<dt>/<dd>元素创建<dl>表并进行编辑。 但是,这仅适用于一个<dl>表,因为当我有多个表时,我无法找到所选的表,每个表都有自己的唯一ID。

我可以访问plugin.js文件中选定的<dl>表。 使用声明的var如下检索它

onShow: function () {
                var sel = editor.getSelection(),
                    element = sel.getStartElement();

                selectedDL = element.getAscendant('dl', true);
                if (selectedDL) {
                    alert(selectedAccordion.getAttribute('id'));
                }
            },

但是,我无法弄清楚如何在对话框iframe中获取所选DT的ID。 我的插件解决方案基于以下链接:

CKEditor 3.x-将UI元素动态添加到插件对话框

我通常的解决方案是在页面加载时通过计数器动态生成ID,然后使用DOM操作将其附加到标签中。 然后,您可以将它们推送到数组中,或者通过数组索引对其进行寻址,也可以通过唯一ID对其进行寻址。

var counter=1;
var dlarray = [];

$( "dl" ).each(function( index ) {
  var idname = "element" + counter.toString;
  $(this).attr('id', 'idname');
  dlarray.push(this);
  counter++;
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM