[jQuery] help with an IE bug: "marginTop"
jquery1.3.2, 1.3.1, 1.2.6
IE 6, 7, 8
I have some code for a nested select list that opens child list when
an anchor is clicked on, then retrieves some content through an ajax
call. In between that, I'm displaying my "loading" image, which is
done using a showIndicator() function. That, in turn, makes use of
Alexandre Magno's jquery.center plugin.[1]
IE is choking on it, though. The error is "Invalid argument" and
points to line 1061. That bit of code is right at the end of attr:
if ( set )
elem[ name ] = value;
return elem[ name ];
Line 1061 is the 2nd line there.
I added an alert(name) just above the if() and saw:
position
position
height
top
marginTop
I changed the code to:
if ( set && name != 'marginTop')
elem[name] = value;
return elem[ name ];
And it worked like a charm in all 3 versions. This is what led me to
understand it was the center plugin causing the problem. Part of that
code includes:
var cssProp = {
position: 'absolute'
};
if(op.vertical) {
cssProp.height = height;
cssProp.top = '50%';
cssProp.marginTop = halfHeight;
}
if(op.horizontal) {
cssProp.width = width;
cssProp.left = '50%';
cssProp.marginLeft = halfWidth;
}
//check the current position
if(positionType == 'static') {
$self.parent().css("position","relative");
}
//aplying the css
$self.css(cssProp);
If I comment out the marginTop line (and remove my change to jquery
itself) everything works. I'm assuming the marginLeft line would have
the same effect.
The really weird thing is that I've used this plugin before without
any problems like this. I haven't gone back to dig up those apps yet;
I thought I'd throw this out here to see if anyone had some idea for a
workaround.
[1] http://www.alexandremagno.net/jquery/plugins/center/