如何解决jQuery UI对话框-不会第一次打开
| 我使用jQuery UI对话框作为确认框,当您单击链接时,该对话框将打开并带有问题和两个按钮。 但是对话框有一些加载问题。当我第一次访问该页面时,该对话框将不会打开。当我按F5再试一次时,它工作正常。 这是我的代码:<script type=\"text/javascript\">
$(document).ready(function() {
var url;
$( \"#dialog\" ).dialog( {
autoOpen: false,resizable: false,modal: true,buttons: {
\"Yes\": function() {
$(this).dialog(\"close\");
window.location.href = url;
},\"No\": function() {
$(this).dialog(\"close\");
}
}
});
$(\"a.supportClub\").click(function(e) {
e.preventDefault();
url = e.target;
$(\"#dialog\").dialog(\"open\");
});
});
</script>
<div id=\"dialog\" title=\"Support club\" style=\"display: none\">
<p>The question</p>
</div>
<a href=\"?supportClub=5\" class=\"button right supportClub\">Support</a>
希望有人能帮助我。
谢谢!
解决方法
$(\"a.supportClub\").click(function(e) {
e.preventDefault();
url = e.target;
$(\'#dialog\').dialog(\'destroy\');
$(\"#dialog\").dialog();
});
,尝试这个 :
<script type=\"text/javascript\">
$(document).ready(function() {
function showDialog(url){
$( \"#dialog\" ).dialog( {
resizable: false,modal: true,buttons: {
\"Yes\": function() {
$(this).dialog(\"close\");
window.location.href = url;
},\"No\": function() {
$(this).dialog(\"destroy\");
}
}
});
}
$(\"a.supportClub\").click(function(e) {
e.preventDefault();
showDialog(e.target);
});
});
</script>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。