我已经查看了很多关于 jquery 模态对话框的页面,但仍然没有找到我需要的东西。
如果用户进行更改并单击我们网站上的内部链接,我希望弹出一个对话框,其中包含 3 个按钮选项——保存、放弃和取消。如果他们点击保存,它会调用保存函数,然后离开页面。
但是该页面设置有选项卡,每个选项卡将不同的 php 页面加载到母版页中。这些链接不是硬链接,它们不会重新加载页面。它们就像页面内锚链接(然后加载一个 php 页面)。所以我无法捕获锚请求并稍后将其发送到地址栏。
我已经有对话框,设置为模态。但是现在,当我单击另一个选项卡时,它会加载该选项卡,并同时弹出我的对话框。我希望它在单击对话框中的按钮之前不加载选项卡。
confirm() 函数完美地做到了这一点。但是我的模态对话框允许加载另一个选项卡。你能帮我设置一个模态对话框,在这种情况下像确认函数一样工作吗?
这是我的 Javascript 函数:
function fw_chkTabStatusFmla() {
if (jsg_fwTabWatchFmla == false) {
$(function() {
$( "#tabWarnFmla" ).dialog({
resizable: false,
height:240,
width:400,
modal: true,
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
},
"Discard": function() {
$( this ).dialog( "close" );
//discard changes and continue
},
"Save": function() {
$( this ).dialog( "close" );
//function to save changes and continue
},
}
});
});
}
}
这是我用的旧的。它正确地停止了行为,但只允许两个按钮。
function fw_chkTabStatusFmla() {
if (jsg_fwTabWatchFmla == false) {
var x = confirm("If you leave this tab without saving you may lose your changes.\n\nClick 'OK' to proceed without saving.");
if (x == true) {
jsg_fwTabWatchFmla = true;
setConfirmUnload(false);
return true;
} else {
return false;
}
}
}
在相关字段中进行更改时,我将 jsg_fwTabWatchFmla 变量设置为 false。
这是我必须运行该功能的内容。
$(document).ready( function() {
$('#tabs').tabs({
select: function(event, ui) {
return fw_chkTabStatusFmla();
}
});
}