阻止 ui 运行得太快

发布于 2024-11-07 06:51:02 字数 699 浏览 0 评论 0原文

下面是我在 asp.net MVC 应用程序中调用操作的 Jquery 函数。在控制器操作中,我正在加载部分视图,该视图加载在 div“结果”中。在控制器操作中,我正在执行数据库操作并使用这些数据加载网格...但是我们有大量记录,这需要时间(例如,对于不同的情况,需要 1-10 分钟)。

为了更好的用户体验,我们决定在加载数据之前阻止 UI 并显示微调器...

下面的 blockui 插件对我有用,但它太快了..它只显示几秒钟,然后就消失了...

如何避免这种情况..任何想法..请帮助....

function RenderPartialView() {
    //block the UI until partial view is rendered
    $.blockUI({ message: '<h3><b><img src="/content/images/loading.gif" /> Please wait while the request is being processed...</b></h3>' });
    //load the partial view
    $('#result').load('@Url.Action("Grid", "Home")', { flip: false });
    //unblock the UI
    $.unblockUI();
}

Below is Jquery function through I'm calling a action in my asp.net MVC application. In controller action I'm loading a partial view, which is loaded in div "result". In controller action I'm performing a database operation and load a grid with these data...but we having huge records whick takes time (say for different situation it is 1-10 minute).

For better user experience, we decide to block the UI and show spinner before data loaded...

below blockui plugging works for me, but it is too fast..it show only for few seconds and then disappier...

how to avoid this..any idea..please help....

function RenderPartialView() {
    //block the UI until partial view is rendered
    $.blockUI({ message: '<h3><b><img src="/content/images/loading.gif" /> Please wait while the request is being processed...</b></h3>' });
    //load the partial view
    $('#result').load('@Url.Action("Grid", "Home")', { flip: false });
    //unblock the UI
    $.unblockUI();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流星番茄 2024-11-14 06:51:02

Load 有一个您可以访问的回调
提供的回调在执行后处理后执行(当检测到成功的响应时)

尝试这个而不是最后两个命令:

//load the partial view
$('#result').load('@Url.Action("Grid", "Home")', { flip: false }, function(){
    //unblock the UI
    $.unblockUI();
});

Load has a callback you can access
The provided callback is executed after post-processing has been performed (When a successful response is detected)

Try this instead of your last two commands:

//load the partial view
$('#result').load('@Url.Action("Grid", "Home")', { flip: false }, function(){
    //unblock the UI
    $.unblockUI();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文