employer_data = functionToGetEmployer();
$.when(fillData()).then(
function(status){
console.log("reaching here");
if(employer_data.detailsMessage !== null){
console.log("reaching here too");
CKEDITOR.instances.employer_detail_message.setData(employer_data.detailsMessage);
}
}
)
fillData: function(){
var dfd = jQuery.Deferred();
$.ajax({
// some ajax call to get some data.
success: function(){
// do something
dfd.resolve("resolved");
},
error: function(){
dfd.reject("rejected");
}
})
return dfd.promise();
}
在上面,ckeditor setData方法无效。
如果我将setData方法保留在promise设置之上,那么它会按预期工作。