我正在尝试在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)
}
喜欢onOk等,但两种方法都没有运气。
有没有办法做到这一点?
提前多多感谢!!
答案 0 :(得分:0)
问题是您必须在页面中定义showMore
功能,而不是对话框的一部分。