-
AuthorPosts
-
March 12, 2015 at 10:52 pm #226417
Hi Christian,
Your given javascript is incomplete so I really can’t help you with that. But if you’re just referring make menu navbar collapse on clicking menu items, then the updated version should be this.
jQuery(document).ready(function($) { $('.x-nav-wrap.mobile .x-nav a').click(function(){ $('.x-btn-navbar').click(); }); });
Hope this helps.
March 13, 2015 at 5:00 pm #226878This works great on the browser, but not on mobile. Is there another statement to make it work on iphone?
Thank you!
March 13, 2015 at 5:12 pm #226886I tried adding in all the previous fixes, hope this makes the code complete
jQuery(document).ready(function($) {
$(‘.x-nav-wrap.mobile .x-nav a’).click(function(){
$(‘.x-btn-navbar’).click();
});
});jQuery(function($){
var window_base = window.location.href.split(“#”).slice(0)[0];
var window_hash = window.location.href.split(“#”).slice(-1)[0];
var outbound = /^https?:\/\//i;$(‘.x-nav a’).each(function(){ //Scan links and convert them to relative hash for one page navigation’s Active statuses to work properly when manually scrolling
var hash = $(this).attr(‘href’).split(“#”).slice(-1)[0];
var anchor_base = $(this).attr(‘href’).split(“#”).slice(0)[0];if(hash) { //Does it have hash? then perform check
if(anchor_base == window_base) { //If same page, then no need to reload, just make it relative
$(this).attr(‘href’, ‘#’+hash);
} // Else, leave it that way. So when user clicked, it will just link them to outbound page
}}).click(function(e){ //Enable Parent and Submenu scrolling
var hash = $(this).attr(‘href’).split(“#”).slice(-1)[0];
if(hash && !outbound.test( $(this).attr(‘href’) ) ) { //Does it have relative hash?
e.preventDefault(); //Disable jumping
e.stopPropagation();setTimeout( function(){
$(‘html,body’).animate({ scrollTop: $(‘#’ + hash ).offset().top – $(‘.x-navbar’).height()},700 ,’swing’);}, 700 );//Now add active status for automatic scrolling
$(‘.x-nav li’).removeClass(‘current-menu-item’);
$(this).parent().addClass(‘current-menu-item’);}
});
$(document).ready(function(){ // Enable auto scroll when loaded.
$(‘.x-nav li’).removeClass(‘current-menu-item’);
//$(‘a:not([href*=”#”])’).parent().addClass(‘current-menu-item’); For experiment onlyif(window_hash) {
$(‘a[href$=”#’+window_hash+'”]’).click(); //Click it, so it will use default click from one page navigation event and submenu event
}
})});
March 13, 2015 at 5:14 pm #226888Actually, that has made the menu items not line up on a browser, so I’m going back to what you just sent which worked on browser, but not on mobile.
jQuery(document).ready(function($) {
$(‘.x-nav-wrap.mobile .x-nav a’).click(function(){
$(‘.x-btn-navbar’).click();
});
});Thanks.
March 14, 2015 at 2:26 pm #227271Hi Christian,
It’s working on my mobile and iphone. This .x-nav-wrap.mobile targets all mobile menu that being displayed. So I don’t see the reason why it will not work just on iphone.
Could you try clearing your iphone’s safari cache?
Thanks!
-
AuthorPosts