问题描述
如果您按ctrl + enter,我会用它来提交表单:
I use this, to submit the form if you hit ctrl+enter:
$(function() {
CKEDITOR.on('instanceReady', function(evt) {
evt.editor.setKeystroke(CKEDITOR.CTRL + 13, 'save');
})
})
不幸的是,这似乎与按提交按钮有些不同。
Unfortunately this seems to be a bit different to pressing the submit button.
如果我按ctrl + enter,则会弹出一个警告窗口,提示该表单中的数据已更改,并且该数据将丢失。如果选择离开页面,则一切正常(不会丢失数据)。
If I hit ctrl+enter I get a popup with a warning that there is changed data in the form, and that this data would get lost. If I choose "leave the page", then everything works fine (not data gets lost).
如何像按提交按钮一样使ctrl + enter正常工作? / p>
How can I make ctrl+enter work like pressing the submit button?
推荐答案
看来,事件在您保存表单时触发。
It appears that the onbeforeunload event is triggered when you save the form.
尝试覆盖保存事件并删除事件处理程序:
Try this to override the save event and remove the event handler:
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');
});
}
这篇关于CKEditor的“保存”与提交不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!