Javascript CKEDIT getData:在提交数据之前等待方法完成
我通过在Javascript CKEDIT getData:在提交数据之前等待方法完成,javascript,asynchronous,ckeditor,Javascript,Asynchronous,Ckeditor,我通过在$(文档)中为每个文本区域调用CKonBlur来注册每个文本区域。就绪(..方法: function CKonBlur(name) { CKEDITOR.instances[name].on('blur', function () { CKsync(name); // push HTML data from CKEDITOR into the associated textarea storeNotifications(name); // su
$(文档)中为每个文本区域调用CKonBlur
来注册每个文本区域。就绪(..
方法:
function CKonBlur(name) {
CKEDITOR.instances[name].on('blur', function () {
CKsync(name); // push HTML data from CKEDITOR into the associated textarea
storeNotifications(name); // submit the textarea to the server
});
}
function CKsync(name) {
$("textarea#" + name).val(CKEDITOR.instances[name].getData());
}
不幸的是,getData
似乎是异步的,我无法找到在(!)提交数据之前等待它完成的方法
问题:如何确保在调用storeNotifications
方法之前完成getData
我还尝试使用checkDirty
但没有成功(它只是使浏览器崩溃):
我100%确定
getData()
不是异步的。setData()
是,但是getData()
不是。它不可能是,因为它返回一个值。你在其他地方有一个bug。我100%确定getData()
不是异步的。setData()
是,但是getData()
不是。它不可能是,因为它返回了一个值。您在其他地方有一个bug。我不知道这是一个bug;一旦我更改了storeNotifications并提交了CKEDITOR.instances[name].getData()的响应直接地,它在所有情况下都能立即正常工作……我不认为这是一个bug;一旦我更改了storeNotifications并提交了CKEDITOR.instances[name].getData()的响应,它在所有情况下都能立即正常工作。。。
function CKsync(name) {
while (CKEDITOR.instances[name].checkDirty() == true);
{
// do nothing
}
$("textarea#" + name).val(CKEDITOR.instances[name].getData());
}