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: Nav.close is not a function" #75

Closed Meidanmor closed 2 years ago

Meidanmor commented 2 years ago

I'm using this wonderful plugin, Thank you for the great work the menu works perfect except one thing: For some reason I can't use the basic events like open() or close() , whenever I try, I'm getting the above ERROR and I can't figure out what's wrong : /

Example of my problem (here the alert is not fired on menu open/toggle event): https://codepen.io/meidanmor/pen/vYZPLNO

Thank you again! I really like this menu and I hope we can fix this..

by the way, I tried to create the menu with Vanila JS and I have an ERROR: "Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. at j (VM873 hc-offcanvas-nav.min.js:17) at n (VM873 hc-offcanvas-nav.min.js:17) at new i (VM873 hc-offcanvas-nav.min.js:17)"

somewebmedia commented 2 years ago

You can't get the reference to the Nav object like that when using jQuery.

Code from here:

var $nav = $('#main-nav').hcOffcanvasNav();
var Nav = $nav.data('hcOffcanvasNav');
Meidanmor commented 2 years ago

@somewebmedia Thank you so much for the fast answer! the easiest things is always the hardest for me to figure haha :] I updated my pen to help some other users..