ComputerWolf / SlickNav

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

Close on Offclick #61

Open nickfmc opened 9 years ago

nickfmc commented 9 years ago

I tried a couple different ways without luck. Is there a way to trigger the close callback when you click anywhere on the (body) that isn't the menu. so that clicking anything except a menu item closes the menu

symeonb commented 9 years ago

There is the close method

So something like $("#mainbodyelement").click(function () { $("#my-menu").slicknav('close') }); will close the menu - this is what i use and it works.

ragscoon commented 9 years ago

It's a nice script, but needs a little more polish, I like that it works with IE8+ but I use JQuery Mobile and when I add the scripts and Css file for JQM on the page, SlickNav will not work, it won't even show up.

Anyone encounter this problem? I only use JQM for the Panels that can slide in and out of the sides.

nickfmc commented 9 years ago

That is what I was trying basically symeonb however because my trigger is inside the #mainbodyelement when I click to open the menu it closes right away because its firing both scripts.

ragscoon please don't hijack threads, start a new issue if you are looking for help.

symeonb commented 9 years ago

ahh yes - my menu is actually outside of the #mainbodyelement - you would have to determine somehow if you are opening the menu or not, and then either close it or not - perhaps the .init callback can help in this instance.

ragscoon commented 9 years ago

Sorry wan't meaning to hijack anything. I used the "close" click feature on a DIV element that comes just inside the body tag and is a wraper for the entire page, so far this works well, but I am also trying to figure out how to add the click function to all the anchor tags in the menu so that when a link is clicked, the menu closes after. I know that if your are moving from page to page the close on click function is not needed, but what if you need it for a link that does not lead from one page to the next?

ragscoon commented 9 years ago

Never mind that last post, I found the CloseOnClick feature in the Javascript set to false, once its set to true the menu closes on click of the anchor tags.