getActiveCarouselItemIndex Error..



  • I got this Error in onsen carousel…

    Uncaught TypeError: Cannot read property ‘0’ of null
    Class.extend._getCarouselItemElements @ onsen.js:7202
    Class.extend._getCarouselItemCount @ onsen.js:7327
    Class.extend.getActiveCarouselItemIndex @ onsen.js:6916
    (anonymous function) @ script.js:661

    i’m using this function for auto carousel …if i navigate to other pages i got this error repeatedly…

    setInterval(function() { 
    var index1 = loginslider.getActiveCarouselItemIndex();
     if (index1 >= 4) { loginslider.first(); } 
     else { loginslider.next(); } }, 6000); 
    


  • @ganeshspear The null means it can’t find the element attached to the DOM you are referencing. Either it doesn’t exist (you navigated to a page it is not on and are still calling the function) or you are calling the function to early in the pages creation and the element hasn’t been created yet (use ons.ready()).


Log in to reply