[英]Best way to hide a loading gif if the user clicks the browser cancel button?
目前,我有一个带有JavaScript函数的kendo菜单,该菜单会弹出加载的gif文件。
Html.Kendo().Menu()
.Name( "menu" )
.Orientation(MenuOrientation.Vertical)
.Items( items =>
{
items.Add().Text( "Company Info" ).Items( cInfoItems =>
{
cInfoItems.Add().Text( "Long Load" ).Url("/Controller/ActionMethod").LinkHtmlAttributes(new{ onclick="return LoadingGif();"});
} );
<script>
function LoadingGif(){
$('#divLoading').show();
}
</script>
问题在于,如果用户单击浏览器的“取消”按钮,则在渲染视图时,gif永远不会隐藏。 处理此问题的最优雅/最流畅的方法是什么?
该死的! 这是旧帖子,但仍然没有答案? 无论如何,对于那些访问过该页面并滚动查找答案的用户,您可以使用的一种处理方法是,
$(document).ready(function () {
// Hide the model or a div; whatever you are using
$(".modal").hide();
//listen for the submit button click
$("#myForm").submit(function (event) {
$(".modal").show();
// set a timeout to hide the gif
setTimeout(function () { $('.modal').hide(); }, 2500);
});
});
也就是说,添加超时。 虽然不是最好的方法!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.