Thursday, 14 March 2013

Apply PIE.htc when revealing an element in IE8

I discovered today that PIE.htc only redraws elements that are visible when the page is loaded. Kinda seems obvious now, but I hadn't planned for this and the testers picked up on some horrible looking buttons on a newly revealed div.

So I had to work out how to apply PIE to an element once it had been revealed. The answer is thus, thanks to a bit of googling and good old SO:
function applyPie(elem) {
    if (window.PIE) {
        elem.css('behavior', 'none');
        elem.css('behavior', 'url("/includes/css/PIE.htc")');
    }
}