Skip to content

JS Error "base.navWidth[i-1] is undefined #209

@clicktravel-sukhwant

Description

@clicktravel-sukhwant

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

<script>$j = jQuery.noConflict();</script>

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

My anythingSlider definition is

     <script type="text/javascript">

        if ( window.XMLHttpRequest )    // Dont do this for IE6          
        {
          $j(function(){

            $j('#sliderFeatures').anythingSlider({ 
              toggleArrows        : true,
              infiniteSlides      : false,
              navigationFormatter : function(index, panel){
                return ['test feature 1', 'test feature 2', 'test feature 3', 'test feature 4'][index - 1];
              },
              navigationSize      : 4,                
              onSlideComplete: function(slider) {
                // keep the current navigation tab in view
                slider.navWindow( slider.currentPage ); 
              }                                                            
            });
          });
        }
      </script>

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! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions