new*_*bie 4 jquery jquery-ui jquery-ui-dialog
我正在使用jquery-ui对话框.我的问题是单击x按钮关闭对话框,我还需要执行cancel()函数.
我怎样才能做到这一点?
var content =
{
autoOpen : false,
modal : true,
width : 350,
minHeight : 50,
height : 350,
position : "center",
resizable : false,
draggable : false,
close : function () {$(".privacy_modal").prop("checked", false);},
buttons:
{
"Cancel": function cancel()
{
$(".privacy_modal").prop("checked", false); $(this).dialog("close");
},
"Accept": function accept()
{
$(".privacy_modal").prop("checked", true); $(this).dialog("close");
}
}
};
Run Code Online (Sandbox Code Playgroud)

注意:使用close不能解决我的问题,因为它在我单击"接受"按钮时会覆盖该功能
您可以使用第三方变量(bAccepts默认为False)和第三方方法.
当用户接受时:
当用户取消时:
当触发onClose时,调用方法doClose(),它执行以下操作:
这是一些未经测试的伪代码.查看工作代码.
var bAccepts = false;
var content = {
autoOpen : false,
modal : true,
width : 350,
minHeight : 50,
height : 350,
position : "center",
resizable : false,
draggable : false,
close : function () { if (bAccepts) {...} else {...} },
buttons: {
"Cancel": function cancel() { bAccepts = false; $(this).dialog("close");},
"Accept": function accept() { bAccepts = true; $(this).dialog("close");}
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14033 次 |
| 最近记录: |