Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1283267
    amp368
    Participant

    Hey there, I’ve used this bit of code to make the mobile menu collapse:

    (function($){
      $('.x-navbar .x-nav-wrap.mobile a').on('touchend click', function(){
        $('.x-nav-wrap.mobile').toggleClass('in').css('height', 0);
        $('.x-btn-navbar').toggleClass('collapsed');
      });
    })(jQuery);

    but doing so causes a link to a modal box to not work on iOS safari.
    It works fine on everything else.
    It’s a simple anchor link so I’m wondering what could be going on.

    The website is http://hlxusa.com/ and the link is careers.
    Any chance you could help?

    Cheers

    #1283563
    Nabeel A
    Moderator

    Hi there,

    Thanks for writing in! Try replacing your code with this:

    jQuery(document).ready(function($){
    	$('.x-nav-wrap.mobile a').on('touchstart', function(e) {
    		$('.x-nav-wrap.mobile').click();
    	});
    });

    Don’t forget to clear your browser’s cache after adding the code. Let us know how this goes!

    #1283668
    amp368
    Participant

    Thanks for the response!

    Unfortunately that didn’t work.
    The menu remains open when you click a link, but the modal works.

    It’s the same result as if there were no code at all.

    I’ve left it in place so you can take a look.

    #1284134
    Paul R
    Moderator

    Hi,

    Kindly change it to this.

    
    jQuery(document).ready(function($){
    	$('.x-nav-wrap.mobile a').on('click touchstart', function(e) {
    		$('.x-btn-navbar').click();
    	});
    });
    

    This is how it works after adding the code.

    See Video – http://screencast.com/t/fLVMvUDD

    #1284611
    amp368
    Participant

    Hi there, sorry that didn’t work either.
    It has the same effect as the code I originally posted.
    Everything works as it should except for the careers link on iOS Safari.
    Nothing happens when it’s clicked.

    #1285029
    Rad
    Moderator

    Hi there,

    Please try this

    jQuery(document).ready(function($){
            $('.x-nav-wrap.mobile a').off('touchstart touchend').on('click touchstart', function(e) {
    		$('.x-btn-navbar').click();
    	});
    
    setTimeout ( function(){ $('.x-nav-wrap.mobile a').off('touchstart touchend'); }, 1000); //Let's make sure it's  off
    
    });

    It’s not working due to touch events, they are captured and not propagated.

    Thanks!

    #1285269
    amp368
    Participant

    That did it!
    Thanks so much, you guys are the best!

    #1285629
    Prasant Rai
    Moderator

    Thanks for the good words. It means a lot to us. Feel free to let us know if you face any other issue. We’ll be happy to assist you. 🙂

  • <script> jQuery(function($){ $("#no-reply-1283267 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>