我的目标是显示一个非模态jquery-ui对话框,该对话框将显示请等待消息以及加载动画。此对话框将显示在用户来自的页面上,而不是继续。我在很大程度上已经用下面的代码工作了。但是,Safari不会显示"请等待"对话框。Firefox和Chrome显示对话框和以下href。Safari只是跟随href,但不会显示对话框。
如果我尝试使用preventDefault();或者返回false;在click事件处理程序中,safari(以及所有浏览器)将显示请等待对话框,但当然它不会遵循href。我希望默认的行为是到点击的href,在到href的时候,我希望对话框显示出来。
我甚至试图做一个点击处理程序,并在里面做一个preventDefault(),然后打开对话框,然后设置窗口。位置或位置。但是Safari仍然会跟随这个href而不显示对话框。
还有人有其他的想法吗?
javascript: $(document).ready(function() {
// Register the pleaseWaitDialog element as a jquery-ui dialog widget with certain options set
$("#pleaseWaitDialog").dialog({
autoOpen: false,
buttons: {},
open: function(event, ui) { $(".ui-dialog-title, .ui-dialog-titlebar-close").hide(); }, // hide the dialog title bar
resizable: false,
show: {effect: 'fade', duration: 500},
height: 120,
width: 300
});
// When a link to add a meeting is clicked, then display the please wait dialog
$("a.addMeetingLink").click(function(e) {
// But wait 5 seceonds before displaying the please wait dialog
setTimeout(function () {
$("#pleaseWaitDialog").dialog("open");
}, 5000);
});
});
HTML: <a href="/ripplemobile/trip/addmeeting/81/1/305/308" class="addMeetingLink">Add Meeting</a>
<div id="pleaseWaitDialog">
<div>
<p>Please wait</p>
<img src="/ripplemobile/images/ajax-loader.gif" />
</div>
</div>
快一点,编辑这个函数:
// When a link to add a meeting is clicked, then display the please wait dialog
$("a.addMeetingLink").click(function(e) {
// ADD
e.preventDefault();
// But wait 5 seceonds before displaying the please wait dialog
setTimeout(function () {
$("#pleaseWaitDialog").dialog("open");
}, 5000);
});