如何在ckeditor中的动态内容中定义onclick()

时间:2012-05-29 11:36:48

标签: onclick ckeditor

我正在尝试在ckeditor中创建一个custome插件。我想要做的是对我的服务器进行ajax调用并获取一个项目列表,我将它动态地呈现在div中。对于这些项目中的每一项,我都设置了一个onclick属性。问题是我得到一个错误,即没有定义onclick属性中的函数。

以下代码段:

对话内容:

contents : [
{
            id : 'information',

            name : 'information',

            label : 'Information',

            elements : [
            {
                type:'vbox',
                padding:0,
                children:[
                {
                    type : 'html',
                    html : '<div style="width: 100%; height: 150px; float: left; border: 1px solid #666666; overflow: auto;" id="results"></div>'
                },
            ]
}]

我在div中插入的列表元素:

var html  = '<a onclick="showMore(' + resultNum + ')">';
        html += result;
        html += '</a>';
        return html;

我试图用这两种方式定义showMore函数:

CKEDITOR.dialog.add('popup', function(editor)
{   
    function showMore() {}
}

CKEDITOR.dialog.add('popup', function(editor)
    {   
        showMore : function() {} (in the return block)
    }

喜欢o​​nOk等,但两种方法都没有运气。

有没有办法做到这一点?

提前多多感谢!!

1 个答案:

答案 0 :(得分:0)

问题是您必须在页面中定义showMore功能,而不是对话框的一部分。