I'm running into an issue where the same javascript on another page works fine but for some reason on this particular page it is throwing an error with the exact same code.
I have a function that gets updated and passed an object of properties to update.
function animateTo(a,t){
var speed,easing,del,cb;
speed = a.speed ? a.speed : 600;
del = a.del ? a.del : 0;
setTimeout(function() {
t.stop(true).animate( { left:a.x, top:a.y, opacity:a.opacity }, { duration: speed, easing: easeOutExpo });
}, del);
}
In IE its saying that a.speed is null. The object that is been passed sometimes has a speed property and sometimes not. So my guess is when its not present its being recognized in IE as null. Is their a way around this. without having to add the speed property to the object everytime.
I thought by saying speed = a.speed ? a.speed : 600; it would set it to 600 if the a.speed was not present.
UPDATE:
I think it may have something to do with the setTimout. The only difference between the two pages are the function being called 3 times at the same time. On the page that it works the calling of the animateTo function is spaced out. It seems when I call it one after another I get the speed is null or not an object only in IE.
Also when I moved the variables inside the setTimout I didn't get that error. But I have to leave the del variable outside the setTimout function and when I do I get an error del is null or not and object in IE.
It would seem on the first call the setTimout works and is able to read a.speed but the second call a.speed is null because the first setTimeout is still trying to find the local variable that's not around. At least that's my theory. Anyone got any ideas around this.