本文介绍了jQuery对话框按钮返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个jquery对话框,我要实现的是当用户按下确定"时,编程继续进行,当按下取消"时,它停止了.
I am using a jquery dialog, and what i want to implement is when user press "ok", the progamming keep going, when press "cancel", it stoped.
function displaymessage()
{
$("#confirm").dialog({
buttons:{
"OK":function(){$(this).dialog("close"); test(1);},
"Cancel":function(){$(this).dialog("close");test(0);}
}
});
function test(bool)
{
if(bool==1)
return true;
else return false;
}
return test();
}
<div id="confirm"></div>
<input type="button" value="Click me!" onclick="return displaymessage()" />
但是在用户单击确定"按钮后如何控制功能测试运行?
But how to control the function test run after user click "ok" button?
谢谢
推荐答案
带2个按钮
<asp:button id="submit" onclientclick="return displaymessage()" />
<asp:button id="submit_hidden" onclick="submit_OnClick" runat="server"/>
隐藏ID为submit_hidden
的按钮. (可能是通过css dsiplay:none;)
Hide the button with id submit_hidden
. (may be via css dsiplay:none;)
然后在jquery中更改代码
And in jquery change the code
$("#confirm").dialog({
autoOpen:false,
buttons:{
"OK":function(){ $("#submit_hidden").click();
$(this).dialog("close"); },
"Cancel":function(){ $(this).dialog("close");}
}
});
现在您不需要返回任何东西.
Now you don't need to return anything.
这篇关于jQuery对话框按钮返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!