CKEDITOR填充Ajax的对话框中选择 [英] CKeditor populate dialog select with Ajax

查看:214
本文介绍了CKEDITOR填充Ajax的对话框中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想填充我CKEDITOR对话框选择框与阿贾克斯。下面是我的plugin.js文件:

I am trying to populate my CKeditor dialog selectbox with ajax. The following is from my plugin.js file:

...
{
    type : 'select',
    id : 'style',
    label : 'Style',
    setup : CKEDITOR.ajax.post(  '.../ckeditor/plugins/simpleLink/ajax.php', JSON.stringify( { foo: 'bar' } ), 'application/json', function( data ) { 
            console.log( data);
    }),
    items : [ ['--- Select something ---', 0] ],
    commit : function( data )
    {
        data.style = this.getValue();
    }
}
...

AJAX的输出是这样的:

The ajax output looks like this:

["Basketball","basketball"],["Baseball","baseball"],["Hockey","hockey"]

我真的想知道如何得到输出进入项目。从我的角度来看我什么都试过。 有人可以帮我吗?

I am really wondering how to get the output INTO the "items". From my point of view I tried everything. Can someone help me?

推荐答案

找到一个解决办法。对于任何人有同样的问题 - 这是我解决它的办法:

Found a workaround. For anyone having the same problem - here is my way of solving it:

plugin.js:

plugin.js:

此之前,codeCKEDITOR.plugins.add('PLUGINNAME',{...

jQuery.extend({
getValues: function(url) {
    var result = null;
    $.ajax({
        url: url,
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            result = data;
        }
    });
   return result;
}
});
var results = $.getValues('.../ckeditor/plugins/PLUGINNAME/ajax.php');

这是code的选择框

{
    type : 'select',
    id : 'style',
    label : 'Style',
    setup : '',
    items : results,
    commit : function( data )
    {
        data.style = this.getValue();
    }
}

这篇关于CKEDITOR填充Ajax的对话框中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆