ProLoser/AnythingSlider — Issue #209: JS Error "base.navWidth[i-1] is undefined
Author: clicktravel-sukhwant
Created: 2011-11-03 12:26:30+00:00
State: open

Hi All,

I have constructed an anythingSlider with 4 tabs contain 4 embedded youtube videos and a bit of text below them.
Everything seems to be working fine, the slides all work, the videos pause and play when a tab is slide too, etc

However I've noticed a js error occuring whenever I slide a tab...

base.navWidth[i-1] is undefined (Line 308) in jquery.anythingslider.js

This is my setup:-

js/jquery-1.6.4.min.js

js/jquery.easing.1.2.js
js/swfobject.js
js/jquery.anythingslider.js
js/jquery.anythingslider.video.min.js

My anythingSlider definition is

I've currently suppressed the error by adding this into jquery.anythingslider.js

base.navWidth = function(x,y){
var i, s = Math.min(x,y),
e = Math.max(x,y),
w = 0;
for (i = s; i < e; i++) {
if (typeof base.navWidth[i-1] != "undefined") // <= check if it's defined first
{
w += base.navWidths[i-1] || 0;
}
}
return w;
};

On initialisation the JS seems to run through

- base.buildNavigation function,
- into the (o.buildNavigation && (base.pages > 1)) IF,
- skips the (o.navigationSize !== false && parseInt(o.navigationSize,10) < base.pages) IF - this is where base.navWidths variable is defined!?

During a slide

base.navWidth is called from base.navWindow and errors on the w += base.navWidths[i-1] || 0; statement. The anythingSlider still works I just keep getting the js errors. Seems to me it's running through code it doesn't need to?

Don't know enough about how everything else works in anythingSlider to get to the bottom of it.

Any help appreciated! :)