本文介绍了如何在母版页中使用jQuery BlockUI进行加载,请等待Message ..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为我的应用程序实现jquery blockUI.我有这段代码.

I need to implement jquery blockUI for my application.. I have this code..

 $.blockUI({ css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
        } }); 

        setTimeout($.unblockUI, 2000); 
    }); 

我将这些代码保留在视图中的每个click函数中.然后它可以正常工作.但是我需要使该代码集中化,以便在某些时间超过2000毫秒的情况下将此代码保存在主文件中,我可以显示jQuery BlockUI吗?对于我的整个应用程序.如果可以的话,请问有人可以帮我如何将这段代码保存在母版页中吗,我需要在母版页中实现哪种代码才能访问此jQuery blockUI?

I am keeping this code in each click function in my views.. then it working fine. but I need to make this code centralized that is keeping this code in master file if something is taking more than 2000 milliseconds can I show do jQuery BlockUI? for my entire application. if so please can any one help me out how to keep this code in master page what kind of code I need to implement in master page to access this jQuery blockUI?

推荐答案

我这样做:

在母版页中,我添加了脚本参考和对自定义脚本的参考,其中包含以下代码

In the masterpage I have added the script reference and a reference to a custom script where I have the following code

//Set Defaults values for blockUI
$.blockUI.defaults.theme = true;
$.blockUI.defaults.title = 'Please wait...';
$.blockUI.defaults.message = '<img src="_assets/images/blockUI_Loader.gif" />';
$.blockUI.defaults.css = {};
$.blockUI.defaults.themedCSS = {};
$.blockUI.defaults.themedCSS.width = 100;
$.blockUI.defaults.themedCSS.height = 64;
$.blockUI.defaults.overlayCSS = {};
$.blockUI.defaults.overlayCSS.backgroundColor = '#ffffff';
$.blockUI.defaults.overlayCSS.opacity = 0.6; 

然后,当我不得不在ajax调用中使用它时,我只需使用

Then when I have to use it in ajax calls I simply use

$("#element").block();
$.ajax({
    type: "get",
    dataType: "html",
    url: "some/url",
    data: {},
    success: function (response, status, xml) {
        $("#element").unblock();
    },
    error: function (response) {
        $("#element").unblock();
    }
});

这篇关于如何在母版页中使用jQuery BlockUI进行加载,请等待Message ..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 12:59