由网友(安于现状丶)分享简介:我想填充我CKEDITOR对话框选择框与阿贾克斯。下面是我的plugin.js文件:I am trying to populate my CKeditor dialog selectbox with ajax. The following is from my plugin.js file:...{type :...
我想填充我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();
}
}
相关推荐
最新文章