Support » Plugin: Page scroll to id » Mobile menu not auto close with anchor link

  • Resolved romeozaaa

    (@romeozaaa)


    please help me i want to know how to fix it

    it’s ok with pc browser but i want to make it auto close menu when i click anchor link in mobile browser

    thank you for help me

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 26 total)
  • Plugin Author malihu

    (@malihu)

    Closing your mobile menu is a menu function (not a “Page scroll to id” one).

    Can you add javascript in your theme? If yes, I can give you some js code to add so that the menu is closed when you click a menu link.

    For example, you can add something like the code below in your theme’s footer.php (right before the closing body tag):

    <script>
    (function($){
    	$(window).on("load",function(){
    		$("body").on("click",".vl-mobile-menu a._mPS2id-h",function(){
    			$(".vl-mobile-menu .vl-burger").trigger("click");
    		});
    	});
    })(jQuery);
    </script>

    wow you are a great man dude it working thankyou so much

    Plugin Author malihu

    (@malihu)

    You’re welcome ๐Ÿ™‚

    Hello, i would really appreciate the same help with my site. I need the javascript to autoclose mobile menu after click.

    Please, it would really help me. Thx.

    site i need to help with: http://casudost.com

    Plugin Author malihu

    (@malihu)

    @vojikvo Try changing your script to:

    <script>
    (function($){
    	$(window).on("load",function(){
    		$("body").on("click","#mobile-navigation .menu-item a[href*='#']",function(){
    			$(".tg-mobile-menu-toggle.tg-mobile-menu-toggle--opened")[0].click();
    		});
    	});
    })(jQuery);
    </script>

    Hope this helps

    Can you please help me too. I canยดt fix that.
    https://bit.ly/2FeNBX5

    Plugin Author malihu

    (@malihu)

    @valerikluger I don’t know in which page you use “Page scroll to id”. Please provide more info and the steps to reproduce the issue(s).

    I have solved the problem with this code. Thanks anyway ๐Ÿ™‚

    (function($) {
    $(‘.menu-item’).on(‘click’, function(){
    if ( $(this).data(‘toggle’) !== ‘dropdown’ ) {
    $(‘.menu-button.active’).click();
    }
    });

    })(jQuery);

    Hi. Can you help me? I have the same problem. My menu does not close when I select an option. http://www.justforfun.es/bocca

    Plugin Author malihu

    (@malihu)

    @quema Hi. This is a support forum for “Page scroll to id” plugin only. You don’t seem to be using the plugin in your site(?)

    Sorry. It was deactivated because it does not work for me. I’ve activated it again

    Plugin Author malihu

    (@malihu)

    Add the code below in your themeโ€™s footer.php (right before the closing body tag and after wp_footer() function):

    <script>
    (function($){
      $(window).on("load",function(){
        $(".menu-item a[href*='#']").on("click",function(){
          if($(".tve-m-expanded").length) $(".tve-m-trigger")[0].click();
        });
      });
    })(jQuery);
    </script>

    Hi, I got the same problem, is there a fix on its way… seems to be a common problem?

    Plugin Author malihu

    (@malihu)

    @niwin Hi,

    This is not a problem of “Page scroll to id”.

    The issue of a mobile menu not closing after a link is clicked, does not come from the plugin. A menu’s closing (and opening) is a functionality of the menu itself. “Page scroll to id” functionality is to scroll the page and “connect” links with targets.

    Closing a menu is out of plugin’s scope and there’s no way to do it automatically, simply because this functionality comes from the script that handles the menu (which might be a theme script or another plugin).

    In short, there’s no fix for this because it’s not something that can be fixed within the plugin.

    All the solutions I’ve provided here are custom scripts that are unrelated to “Page scroll to id”. I provide these solutions simply because I wanna help users that happen to use “Page scroll to id”.

    Basically, these solutions should come from the mobile menu developer(s).

    The real issue with these menus is that their developer(s) do not take into account (when developing the menus), that a menu item might lead to an anchor within the page. Most developers (wrongly) assume that all menu links go to other pages, so they don’t program the menu to close after a link is clicked.

    This issue just happens be more prevalent when you use “Page scroll to id” because you happen to have menu items that do lead to anchors/targets within the page. You’d notice the same problem even if you didn’t use “Page scroll to id”.

    Anyway, if you do have this problem, I’ll need to see your page in order to provide a solution. Please keep in mind that such solution is specific to your menu and requires an extra js script.

    Hope this helps ๐Ÿ™‚

    Sry for the late reply. I understand, its bad practice from theme devs, which is unfortunately… you are very kind to help. My site:

    https://jakobkristin.se

    If your solution work for me, I would be very grateful ๐Ÿ˜€

Viewing 15 replies - 1 through 15 (of 26 total)
  • You must be logged in to reply to this topic.