ComputerWolf / SlickNav

Responsive Mobile Menu Plugin for jQuery
MIT License
939 stars 314 forks source link

this.mobileNav.on not a function #92

Closed koldsnapz closed 9 years ago

koldsnapz commented 9 years ago

I can only open the initial menu from the Label. After that, none of the parent links open anything. This is not the case for the demo files. I tried changing the .js source to the one located in the /dist folder which is what the demo uses, but it still breaks.

ComputerWolf commented 9 years ago

@koldsnapz, can you link to a jsfiddle or codepen so I can see your code and debug?

koldsnapz commented 9 years ago

https://jsfiddle.net/fkjgdymj/

But as I build the code in the fiddle I noticed it started working (not properly setup yet so it looks ugly) but the issue may be a conflict of my Drupal environment...

koldsnapz commented 9 years ago

Looks like it has to do with the version of jQuery used.. less than 1.7 causes it to break.

esteinborn commented 9 years ago

I have looked at this and made it completely compatible with jQuery 1.4.2+

need to switch the .on calls to .delegate and swap the selector and event like so:

Change: $this.mobileNav.on('click', '.' + prefix + '_item', function (e) { to: $this.mobileNav.delegate('.'+prefix+'_item', 'click', function(e){

and

Change: $this.mobileNav.on('keydown', '.'+prefix+'_item', function(e) { to: $this.mobileNav.delegate('.'+prefix+'_item', 'keydown', function(e) {

Be advised, I'm using the version that ships with Drupals adminimal_admin_menu module.

OPCIT commented 6 years ago

Also needed to change

$this.mobileNav.on('keydown', '[role="menuitem"]', function(e) { to $this.mobileNav.delegate('[role="menuitem"]', 'keydown', function(e) {