Search code examples
user-interfacejquery-mobileloadingblock

How to block UI using pageLoading in jQueryMobile


Is it possible to block the UI when using $.mobile.pageLoading(false)?


Solution

  • This feature isn't implemented in jQueryMobile Alpha 1.0a4.1.

    I solved the problem adding a overlay div with high enough z-index.

    JS:

    $(document).ready(function () {         
        $('body').append('<div id="block-ui"></div>');      
    
        $('#ajax_request').click(function(){        
            $('#block-ui').show();
            $.mobile.pageLoading(false);
        });
    });
    

    CSS:

    #block-ui {
        display: none;
        cursor: wait;
        position: absolute;
        top: 0px;
        left: 0px;  
        width: 100%;
        height: 100%;
        z-index: 9; 
        background-color: #CCCCCC;
        opacity: 0.5;
    }
    

    If you're using using fixed-bars you need to override z-index value:

    .ui-header-fixed, .ui-footer-fixed {
        z-index: 8 !important;
    }