Reputation: 4740
How can I test if some div is blocked ?
I'm using BlockUI plugin.
$("#containerVenda").block({ message: "Block" });
I want to do a IF statement to know if the DIV is blocked or not.
Upvotes: 0
Views: 1784
Reputation: 207501
Look at the classes that were applied to the element containerVenda after you made it block(). See what was added. Than do a check
var elem = $("#containerVenda");
if( elem.hasClass("theAddedClass") ){
//I am a block thingy already.
}
Upvotes: 0
Reputation: 15338
not sure but try this : http://jquery.malsup.com/block/
$(document).ready(function(){
$("#containerVenda").blockUI({
onBlock: function() {
$("#containerVenda").addClass("blocked");
}
});
$("#mybutton").click(function(){
if($("#containerVenda").hasClass("blocked")){
alert("containerVenda is blocked");
}
})
})
Upvotes: 0
Reputation: 71908
I looked into the plugin's code, and it seems it doesn't expose any methods to test if an element is blocked or not. However, it sets some data to the element, which you could try checking. Something like this:
var blockableElement = $("#containerVenda").block({ message: "Block" });
alert("Is blocked? " + blockableElement.data('blockUI.isBlocked'));
Upvotes: 4
Reputation: 9822
Not documented, but $("#containerVenda").data('blockUI.isBlocked')
seems to be the easiest way.
Upvotes: 2