CKEditor 'save' 不同于提交
CKEditor 'save' is different than submit
我用这个,如果你按 ctrl+enter 来提交表单:
$(function() {
CKEDITOR.on('instanceReady', function(evt) {
evt.editor.setKeystroke(CKEDITOR.CTRL + 13, 'save');
})
})
不幸的是,这似乎与按下提交按钮有点不同。
如果我按 ctrl+enter,我会弹出一个警告,警告表单中的数据已更改,并且这些数据将会丢失。如果我选择 "leave the page",那么一切正常(不会丢失数据)。
如何使 ctrl+enter 像按提交按钮一样工作?
您是否尝试将 "save" 替换为 "submit"。
CKEditor 有一个缓存,可以保存你输入的内容,所以当你失去连接等时,你的内容不会消失。
似乎在您保存表单时触发了 onbeforeunload 事件。
试试这个来覆盖保存事件并删除事件处理程序:
for (var i in CKEDITOR.instances) {
CKEDITOR.instances[i].on('save', function(evt) {
window.onbeforeunload = null;
// if the above line doesn't work,
// replace it with the next line removing the two slashes
// $(window).off('beforeunload');
});
}
我用这个,如果你按 ctrl+enter 来提交表单:
$(function() {
CKEDITOR.on('instanceReady', function(evt) {
evt.editor.setKeystroke(CKEDITOR.CTRL + 13, 'save');
})
})
不幸的是,这似乎与按下提交按钮有点不同。
如果我按 ctrl+enter,我会弹出一个警告,警告表单中的数据已更改,并且这些数据将会丢失。如果我选择 "leave the page",那么一切正常(不会丢失数据)。
如何使 ctrl+enter 像按提交按钮一样工作?
您是否尝试将 "save" 替换为 "submit"。
CKEditor 有一个缓存,可以保存你输入的内容,所以当你失去连接等时,你的内容不会消失。
似乎在您保存表单时触发了 onbeforeunload 事件。
试试这个来覆盖保存事件并删除事件处理程序:
for (var i in CKEDITOR.instances) {
CKEDITOR.instances[i].on('save', function(evt) {
window.onbeforeunload = null;
// if the above line doesn't work,
// replace it with the next line removing the two slashes
// $(window).off('beforeunload');
});
}