[英]Show 'saving…' message with js/jQuery and then redirect to page
I'm trying to show a saving....
message upon clicking an asp button on my page. 单击页面上的一个ASP按钮后,我试图显示一个saving....
消息。
I have most of it working however the fadeOut
isn't working for me, the message will flash on the screen, then disappear and the redirect will occur. 我的大部分内容都可以使用,但是fadeOut
不适用于我,该消息将在屏幕上闪烁,然后消失,然后进行重定向。
This is the code: 这是代码:
$(document).ready(function () {
$("input[id$='btnSaveBanners']").click(function () {
var elem = $('#save-msg');
elem.toggle();
elem.fadeOut(3000);
setTimeout(function () { window.location.href = "/Admin/Orders/ViewAll.aspx"; }, 5000);
});
});
And the element defined on my page: 以及在我的页面上定义的元素:
<span id="save-msg" style="display:none;">Saved...</span>
I thought maybe the call to toggle()
was interfereing with the animation somehow so I tried removing the style
attribute to clear the display:none;
我以为对toggle()
的调用可能以某种方式干扰了动画,因此我尝试删除了style
属性以清除display:none;
which didn't help at all. 这根本没有帮助。 I'm using jQuery 1.7.2
and jQuery UI 1.7.2
. 我正在使用jQuery 1.7.2
和jQuery UI 1.7.2
。
I've created a jsFiddle of the problem which works using the exact same code yet when running locally the Saved...
message just flashes on screen and then the redirect occurs. 我创建了一个的jsfiddle本地运行时使用的作品完全相同的代码,但问题的Saved...
消息只是闪烁在屏幕上,然后重定向发生。
Any suggestions on something else to try? 对其他尝试有什么建议吗?
Try fadeOut callback method. 尝试fadeOut回调方法。 Like shown below. 如下图所示。
$(document).ready(function () {
$("input[id$='btnSaveBanners']").click(function () {
var elem = $('#save-msg');
elem.toggle();
elem.fadeOut(3000, function () {
setTimeout(function () { window.location.href = "/Admin/Orders/ViewAll.aspx"; }, 5000);
});
});
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.