CKEditor' save'与提交不同 [英] CKEditor 'save' is different than submit
本文介绍了CKEditor' save'与提交不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果您按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正常工作?
How can I make ctrl+enter work like pressing the submit button?
推荐答案
看来, onbeforeunload 事件.
尝试使用此方法覆盖保存事件并删除事件处理程序:
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' save'与提交不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文