Error on scroll


Topic: Error on scroll

Cynthia Sánchez García pro asked 7 years ago

Hi, I have downloaded the version 4.4.3, but after updating the libraries on my site, I´m getting an error regarding to `Cannot read property 'top' of undefined`. Checking the code, I saw this piece: ``` $(window).scroll(function () { if ($('.navbar').offset().top > OFFSET_TOP) { $('.scrolling-navbar').addClass('top-nav-collapse'); } else { $('.scrolling-navbar').removeClass('top-nav-collapse'); } }); ``` I´m not using `navbar` on my site, could you please to check if `navbar` exists to run the piece of code. Thanks

Jakub Strebeyko staff answered 7 years ago

Hi Cynthia, To resolve this issue instantly, you can wrap the existing if checking for navbar offset in another, checking whether such an element exists at all, for example:
if ( $( '.navbar' ).length ) { [navbar offset if's] }
Thank you for pointing it out - we will implement fix in the next release.

With Regards,
Kuba

Cynthia Sánchez García pro commented 7 years ago

Thanks Kuba

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Closed

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No