0

Im trying to write a function where I click a hamburger menu, and it opens, then clicked again it closes. I've tried many examples, but it always returns an error of "Cannot read property 'pattern' of undefined" the second time I click the menu. The example I'm referencing is here https://codepen.io/filippo/pen/WvGbJB?editors=1010. Am I missing something here?

My code is as follows:

         $('.menu').click( function ( event ) {

            if( $(event.target).hasClass('open') ) {

                $('.full-menu').velocity({ width: "0%" }, { duration: 100 });
                $('.menu').removeClass('open');
                $('.full-menu').addClass('hide-menu');

            } else {
                $('.full-menu').velocity({ width: "100%" }, { duration: 100 });
                $('.full-menu').removeClass('hide-menu');
                $('.menu').addClass('open');
                bindmenus()
            }
        });
user1218670
  • 31
  • 1
  • 3
  • The codepen doesn't seem to be throwing an error. – hassassin May 31 '18 at 23:35
  • Yes, the example I'm following is working, but when I try to use this code, I get an error. – user1218670 May 31 '18 at 23:45
  • My initial thoughts are A) You are forgetting to instantiate something in your code (either the JS or a sub of it?) or B) You're running local on the client only. Try running in in other browsers (Firefox, Edge). I don't know all the minute details, but I believe AJAX has a big part to do with this https://stackoverflow.com/a/38344639/2970056 – heb-NR May 31 '18 at 23:50
  • I am running this locally, but I am using velocity.js on other aspects of my site - and they all work fine. It appears to be a problem only related to the click event. – user1218670 May 31 '18 at 23:55

0 Answers0