我在弹出颜色框中有一个表单,如果用户编辑其中一个文本框,然后单击取消,我想要一个弹出窗口,显示类似“您确定要离开而不保存吗?”的内容。目前我显示了弹出窗口,但它是在弹出颜色框已经关闭后显示的
用户表页面
$('a.openDialog').colorbox({
iframe: true,
transition: "elastic",
width: "75%", height: "90%"
});
实际表格页面
$(':input', 'form').bind("change", function () {
setConfirmUnload(true);
});
function setConfirmUnload(on) {
window.onbeforeunload = (on) ? unloadMessage : null;
}
function unloadMessage() {
return 'You have entered new data on this page.' +
' If you navigate away from this page without' +
' first saving your data, the changes will be' +
' lost.';
}
最佳答案
您可以使用颜色框回调 onCleanup 或 onClose 如果这没有帮助您可以在关闭按钮或 div 上添加监听器
关于javascript - 在带有 colorbox 弹出窗口的表单上添加 "are you sure you want to leave page without saving",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14821285/