How to determine if jQuery BlockUI is blocking a page

Very similar to this question , except that I am not blocking a specific element, I am blocking the entire page.

So, instead of:

$('div.test').block({ 
    message: '<h1>Processing</h1>', 
    css: { border: '3px solid #a00' } 
}); 

I do:

$.blockUI({ 
    message: $('#divModal1'), 
    css: { cursor: 'default' }
});

I tried to use htmland bodyas a selector.

var data = $('html').data();

if (data['blockUI.isBlocked'] == 1) {
    alert('blocked');
}
else {
    alert('not blocked');
}

But data['blockUI.isBlocked']always 'undefined'

+3
source share
1 answer

I looked at the source; it looks like the data is being written to window, not to htmlor body. See the fiddle here:

http://jsfiddle.net/nAQ94/

$.blockUI({ 
    message: $('#divModal1'), 
    css: { cursor: 'default' }
});

console.log($(window).data());

The call console.logreturns the following object:

> Object {blockUI.history: Object, blockUI.onUnblock: null, blockUI.isBlocked: 1}

+3
source

All Articles