Close menu on click outside of menu area
9 years 1 month ago #29976
by cme
Replied by cme on topic Close menu on click outside of menu area
Thanks for the input. When firing the click event using
I always ended up in an endless recursion, although I don't have a clue why...
But I think I found a pretty simple solution. At least it seams to work so far:
I will test it a little more before going live.
cme
Code:
$('li.accordeonck.open').trigger('click');
But I think I found a pretty simple solution. At least it seams to work so far:
Code:
$( "body" ).click(function( event ) {
if(!event.target.hasClass("toggler")){
$('li.accordeonck.open').removeClass('open');
$('ul.content_1').hide();
}
});
I will test it a little more before going live.
cme
Please Log in or Create an account to join the conversation.
9 years 1 month ago - 9 years 1 month ago #30010
by cme
Replied by cme on topic Close menu on click outside of menu area
For some reason not working on iPads. Desktops and android tablets are fine.
I extended the if condition a little bit in order to keep the menu open until a new page is loaded if a link is clicked.
cme
I extended the if condition a little bit in order to keep the menu open until a new page is loaded if a link is clicked.
Code:
<script type="text/javascript">jQuery(function($){
$( "body" ).click(function( event ) {
if(!event.target.hasClass("toggler")&&event.target.nodeName!="A"){
$('li.accordeonck.open').removeClass('open');
$('ul.content_1').hide();
}
});
});</script>
cme
Last edit: 9 years 1 month ago by cme.
Please Log in or Create an account to join the conversation.
9 years 1 month ago #30011
by ced1870
Joomlack Webmaster and Developer
Replied by ced1870 on topic Close menu on click outside of menu area
thank you for sharing your solution. As you can see, it is not so easy to do that
Joomlack Webmaster and Developer
Please Log in or Create an account to join the conversation.
Time to create page: 0.202 seconds