I am trying to put my ajax call returned data and other codes in one function.
This is for custom fckeditor plugin.
I have something like
function customTag(editor){
var id = editor.config.id;
var instance = this;
//my custom ajax wrapper…….
//the 'dbData' is holding the returned data from ajax.
ajax.onFinished = function(dbData){ console.log(dbData)};
//I want to return this object and use my ajax returned data
return {
title:'Link',
minWidth : 200,
minHeight : 200,
buttons : [CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton],
contents: [
{
id:'tab',
label: 'test here',
elements: [
{
type:'select',
id:'select box',
//I want to use the returned data below
items: [[dbData[0],0],[dbData[1],0] ]
}
]
}
]
}
}
CKEDITOR.dialog.add('customTag', function(editor){
return customTag(editor);
});
How would I be able to solve this. Thanks a lot!
Perform CKEDITOR.dialog.add()
inside ajax.onFinished
. In there, create the return object and use it directly for CKEditor. Either that, or use synchronous operations. Something like this:
ajax.onFinished = function(dbData){
var o = {
title:'Link',
minWidth : 200,
minHeight : 200,
buttons : [CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton],
contents: [
{
id:'tab',
label: 'test here',
elements: [
{
type:'select',
id:'select box',
items: [[dbData[0],0],[dbData[1],0] ] // Use dbData
}
]
}
]
};
CKEDITOR.dialog.add('customTag', function(editor){
return o;
});
};
If CKE has issues with calling dialog.add
after it's been initialized, initialize it inside ajax.onFinished
too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.