somewebmedia / hc-offcanvas-nav

JavaScript library for creating toggled off-canvas multi-level navigations, allowing endless nesting of submenu elements, supporting swipe gestures, keyboard interactions and ARIA attributes.
https://somewebmedia.github.io/hc-offcanvas-nav/
MIT License
336 stars 82 forks source link

Uncaught TypeError: hcOffcanvasNav is not a constructor #53

Closed dpetratsch closed 3 years ago

dpetratsch commented 3 years ago

Hey there,

i just cant get this plugin to work - i'm always getting the same error:

Uncaught TypeError: hcOffcanvasNav is not a constructor

Its the same with vanilla and jQuery.

My version is: 6.0.4

Thanks for any help. Daniel

somewebmedia commented 3 years ago

Can you please state more details, whats your dev environment, how are you initiating it?

dpetratsch commented 3 years ago

Yes sure:

Windows 10 with Chrome Version 86.0.4240.111 hcOffcanvas 6.04 via NPM jQuery V 3.5.1

I tried initiating with both methods exactly as described in the docs:

Vanilla:

document.addEventListener('DOMContentLoaded', function() {
  var Nav = new hcOffcanvasNav('#main-nav', {
    disableAt: 1024,
    customToggle: '.toggle',
    navTitle: 'All Categories',
    levelTitles: true,
    levelTitleAsBack: true
  });
});

and

jQuery:

jQuery(document).ready(function($) {

  $('#main-nav').hcOffcanvasNav({
    disableAt: 1024,
    customToggle: $('.toggle'),
    navTitle: 'All Categories',
    levelTitles: true,
    levelTitleAsBack: true
  });

});

Both methods lead to the same error when initiating:

error

Thanks! Daniel

somewebmedia commented 3 years ago

If you are using NPM, are you also using some kind of compiler for your scripts like Gulp, Babel etc? How are you including the script exactly?

dpetratsch commented 3 years ago

Yes i'm using gulp to merge my scripts together - but without any transpiler or compression, just a plain merge so this should not be the source of the problem.

I already included the Script directly from the NPM folder without any modification which leads to the same error. The script is included via Githubissues.

  • Githubissues is a development platform for aggregating issues.