blockUI无法正常工作 [英] blockUI is not working

查看:276
本文介绍了blockUI无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,我正在使用阻止ui,但它没有阻止页面.我正在使用ajax调用来获取用户控制结果(部分视图)以加载到页面中的div中.使用blockui完成整个页面.

I have folowing code where i am using block ui,but its not blocking the page.i am using ajax call to get user control result (partial view) to load into div in page.during ajax call i want to block the complete page using blockui.

 $('#btnGO').click(function() {


        if (validate()) {
            alert("loading");
            $.blockUI({ message: '<img src="/Content/images/ajax-loader.gif"/>' }); //this is not working

            $.ajax({

                type: "POST",
                url: "/Controller/action/", //to get the partial view
                async: false,
                cache: false,
                beforeSend: function() {

                },
                complete: function() {
                    alert("ajax complete event")
                    $.unblockUI(); 
                },

                data: $('#frmPassBook').serialize(),
                error: function(xhr, status, error) {
                    $('#ErrorMessage').html(xhr.responseText);
                    $("#ErrorMessage").stop().show('slow');
                    $('#ui-widget').show();
                    $.unblockUI();
                },
                success: function(data) {
                    $("#aCBDetails").parent().show();
                    $("#divCBDetails").hide("blind");
                    $("#aCBDetails span:first").removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
                    $('#ui-widget').hide();
                   //loading html in div
                   $("#div").html(data);

if ($("#rbMain") != undefined) {

                        if ($("#rbMain").attr("checked")) {
                            $(".subTrId").hide();
                            $("#spSub").hide();
                            $("#spMain").show();

                        }
                        else {
                            $(".subTrId").show();
                            $("#spSub").show();
                            $("#spMain").hide();

                        }
                    } else {

                        $("#spSub").show();
                        $("#spMain").hide();
                    }

//unblocking after div is loaded with html
                   $.unblockUI();
                }
            });
        } else {

           $.unblockUI();

        }
        return false ;
    });

推荐答案

使用 baseZ 索引来阻止整个页面 例如.

Use the baseZ index to block the whole page eg.

$.blockUI({ 
                                            message: "<img src="/Content/images/ajax-loader.gif"/>",
                                            baseZ: 9000,
                                            css: { 
                                                top:  ($(window).height() - 400) /2 + "px", 
                                                left: ($(window).width() - 400) /2 + "px", 
                                                width: "400px"} 
}); 

这篇关于blockUI无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆