malsup / blockui

jQuery BlockUI Plugin
http://jquery.malsup.com/block/
1.69k stars 506 forks source link

$(window).block() throws an exception #61

Closed begrossi closed 11 years ago

begrossi commented 11 years ago

I undrestand that to block entire window I should call $.blockUI(). It only calls install function to window element. But I need created an facility in my code to block some element, and, if I dont pass the element, I will assume window. So, I write this simpler code:

function block(element) { $(element || window).block(); }

I think that this code is ok and should work fine. But I found a little problem with this:

$.fn.block throws an exception on this line: this.style.zoom = 1; // force 'hasLayout' in ie

because window has no style property. It can be solved with somethig like this: this.style && this.style.zoom = 1;

Can you fix it?

Thanks, Bruno E. Grossi

malsup commented 11 years ago

Since you already have a convenience function, just handle it there:

function block(element) {
    if (element)
        $(element).block();
    else
        $.blockUI();
}
begrossi commented 11 years ago

Mike,

it's a simplication of my function. I do a lot of things in this methods, like set some data using $().data() to the element that I'm blocking... The fix so simple.. I changed the line to:

if (this.style) this.style.zoom = 1; // force 'hasLayout' in ie

And it solved my problem..