jQuery UI对话框 - 不会第一次打开 [英] jQuery UI Dialog - Won't open the first time
本文介绍了jQuery UI对话框 - 不会第一次打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jQuery UI对话框作为确认框,当您单击链接时,对话框将打开,并显示问题和两个按钮。
但我有对话框的一些负载问题。当我第一次访问该页面时,该对话框将不会打开。当我按F5并再次尝试时,它的工作正常。
I'm using the jQuery UI Dialog as a confirm box, when you click a link the dialog will open with the question and two buttons. But I've got some load problems with the dialog. When I visit the page for the first time, the dialog won't open. When I press F5 and try it again, it works fine.
这是我的代码:
<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>
希望有人可以帮助我。
谢谢!
推荐答案
尝试这样:
<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>
这篇关于jQuery UI对话框 - 不会第一次打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文