Search code examples
jqueryblockui

Block UI Real time message


Please let me know how to change the blockUI message in real time, in the following scenario, without flickering or calling blockUI.

E.g.:

$.blockUI({ message: '<h1>Please wait - calculating Exposure </h1>' }); 
Ajax call1 CalculateExposure()
Ajax call2 CheckStatus() // Will run every 5 seconds for max 2 minutes
{ 
    // Here i want to change block ui page message to checking rates,etc... 
    // This is calling again so page is flickering...
    // $.blockUI({ message: '<h1>checking rates </h1>' });
}     

Solution

  • So, I give you a more exact answer, if it was not clear. Define you first message like this:

    $.blockUI({
        message: '<h1 id="myMessage">Please wait - calculating Exposure </h1>'
    });
    

    Then, after you want to update your message, do this:

    document.getElementById('myMessage').value = 'checking rates';
    

    Or the jQuery way:

    $('#myMessage').text('checking rates');
    

    This will only change the text in the existing blockUI window!

    If you have finished your long process, you can finally unblock the UI:

    $.unblockUI();