SlickNav icon indicating copy to clipboard operation
SlickNav copied to clipboard

Close on Offclick

Open nickfmc opened this issue 10 years ago • 6 comments

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

nickfmc avatar Jan 20 '15 20:01 nickfmc

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.

symeonb avatar Jan 21 '15 08:01 symeonb

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.

ragscoon avatar Jan 21 '15 20:01 ragscoon

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.

nickfmc avatar Jan 22 '15 01:01 nickfmc

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.

symeonb avatar Jan 22 '15 08:01 symeonb

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 avatar Jan 22 '15 14:01 ragscoon

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.

ragscoon avatar Jan 22 '15 14:01 ragscoon