blockUI exception 'parentNode' of undefined
OK finally I fixed the issue. Basically I created a dynamic element and placed content of my loader into that div and used it for blocking.
my upldated myBlock function as follows:
myBlock = function (surroundingControl, message) {
console.log('blocking');
if (message)
$("#loader h4").text(message);
else
$("#loader h4").text('Loading...');
var messageContent = document.createElement('div');
if ($('#loader') !== undefined)
$(messageContent).html($('#loader').html());
else
$(messageContent).html("Loading....");
if (surroundingControl)
surroundingControl.block({ message: messageContent, baseZ: 1200 });
else {
$.blockUI.defaults.message = messageContent;
$.blockUI.defaults.baseZ = 1200;
$.blockUI.apply();
}
};
Usually this problem comes as it could not find the DOM element that's specified in "message" property or message property was not specified at all, in your case you need to make sure that $('#loader')
is returning an element.
Hint: You could even pass message: null
in case you just need to block without displaying any content or loading image.