Ajax issue with Fx.Scroll and IE7/8

35 views
Skip to first unread message

hairbo

unread,
Feb 9, 2012, 11:39:09 AM2/9/12
to mootool...@googlegroups.com
Hi,

Apologies once again for a lack of a fiddle.  Also, in advance, I think there's a better way for me to handle the Javascript, so perhaps the bug I'll describe below could be avoided altogether.  But, I thought this might be of some interest/use to somebody out there.

In any event, I'm making an AJAX call using Mootools Core 1.4.4 and More 1.4.0.1 (using Form.Request), and part of what is returned is a JS call to a function which invokes Fx.Scroll.  Specifically, the code returned contains this:

UTILS.scrolltotop();

"UTILS" is a class that gets initiated on page load, and so the function "scrolltotop()" is defined before the AJAX call ever gets made.  The body of scrolltotop is just this:

var myscroll = new Fx.Scroll(document.body, {
   offset: {
       x: 0,
       y: 0
   }
}).toTop();

In all other browsers I've used, this code executes with no errors, and the window scrolls to the top as I want it to.  However, in IE7 and 8, every so often, I get an error deep inside Mootools more.  It looks like it's bombing in this section of Element.Position:

setOffsetOption: function(element, options){
var parentOffset = {x: 0, y: 0},
offsetParent = element.measure(function(){
return document.id(this.getOffsetParent());
}),
parentScroll = offsetParent.getScroll();

The error returned is:  'null' is null or not an object.

I *think* it's specifically choking on "parentScroll = offsetParent.getScroll()", but IE doesn't always return reliable line numbers.

Clearly this is some sort of race condition that was resolved/masked in IE9.  If I have a simple page that just makes my Fx.Scroll call, I can't get IE8 to throw an error.

Anyway, I don't know that there's anything to be done, other than for me to re-write my code to invoke the call in a different way (or bail on scrolling prior to IE9).


Reply all
Reply to author
Forward
0 new messages