jquery 实现“请稍候”对话框 - safari 特定问题
我的目标是显示一个非模式 jquery-ui 对话框,该对话框将显示一条请等待消息以及加载动画。该对话框将显示在用户来自的页面上,但也不会继续。我基本上已经使用下面的代码完成了这个工作。但是,Safari 不会显示“请稍候”对话框。 Firefox 和 Chrome 显示对话框和以下 href。 Safari 只遵循 href,但不会显示对话框。
如果我尝试 PreventDefault();或返回 false;在单击事件处理程序中,Safari(和所有浏览器)将显示请稍候对话框,但当然它不会遵循 href。所以我确实想要转到单击的 href 的默认行为,只是在转到 href 时,我希望显示对话框。
我什至尝试做一个点击处理程序并在里面做一个preventDefault(),然后打开对话框,然后设置window.location或location.href,但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>
My goal is to display a non-modal jquery-ui dialog box that will display a please wait message along with a loading animation. This dialog box would display on the page the user is coming from, not proceeding too. I largely have this working already with the code below. However, Safari will not display the the please wait dialog. Firefox and Chrome display dialog and following href. Safari just follows the href, but won't display the dialog.
If I try a preventDefault(); or a return false; in the click event handler, then safari (and all browsers) will display the please wait dialog, but of course it will not follow the href. So I do want the default behavior of going to the clicked href, just while going to the href, I want the dialog to display.
I have even tried to do a click handler and inside do a preventDefault(), then open the dialog and then set window.location or location.href, but still Safari will just follow the href and not display the dialog.
Does anyone have any other ideas?
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

快速一点,编辑此函数:
这应该可以解决您当前的问题。
A quick point, edit this function:
This should solve your current issue.