-
AuthorPosts
-
March 23, 2018 at 12:25 pm #931945
Hi,
We are trying to remove the #top from active menu items for mobile menu’s. What happens is the following:
– I click on a link on a mobile device
– When on this page, I click again on the same link
– Result. Nothing happens and the menu does not disappear.This behavior can’t be reproduced in a browser with the toggle device option in the developer tools, because then the link goes to #top. We would like to reload the page when you click on a mobile menu item.
I’ve read https://kriesi.at/support/topic/remove-hash-value-top-from-url/ but my question regards all the menu links (except the submenu’s that are intentionally added with a #)
Link is in the private content section. Hope you can help!
Regards,
DanMarch 24, 2018 at 7:37 am #932235Hey Daniel,
Here is the code you can put in your funtions.php
add_action('wp_footer', 'ava_new_custom_script'); function ava_new_custom_script(){ ?> <script type="text/javascript"> (function($) { function a() { if ($.avia_utilities.isMobile) { var hrefTmp = jQuery(".menu-item-3295 a").attr("href"); jQuery(".menu-item-3295 a").attr("href", hrefTmp.substr(0, hrefTmp.length-4)); } } $(window).load(function() { a(); }); })(jQuery); </script> <?php }
If you need further assistance please let us know.
Best regards,
VictoriaApril 16, 2018 at 9:34 am #942482Hi Victoria,
Thanks and sorry for my late reply! I see this is for one specific link (menu-item-3295). As said in my initial post, I’d like to remove #top from every active menu item, not only the home page. Can you help with that?
Thanks!
DanApril 17, 2018 at 10:11 pm #943273Hi,
add_action('wp_footer', 'ava_new_custom_script'); function ava_new_custom_script(){ ?> <script type="text/javascript"> (function($) { function a() { if ($.avia_utilities.isMobile) { var hrefTmp = jQuery(".menu .active").attr("href"); jQuery(".menu-item-3295 a").attr("href", hrefTmp.substr(0, hrefTmp.length-4)); } } $(window).load(function() { a(); }); })(jQuery); </script> <?php }
Try it like that and let us know if it works
Best regards,
BasilisApril 19, 2018 at 4:22 pm #944150Hi Basilis,
Thanks for helping! It’s not working yet, I assume this second line also needs to be changed?
var hrefTmp = jQuery(".menu .active").attr("href"); jQuery(".menu-item-3295 a").attr("href", hrefTmp.substr(0, hrefTmp.length-4));
I’ve now changed it to
var hrefTmp = jQuery(".menu .active").attr("href"); jQuery(".menu .active").attr("href", hrefTmp.substr(0, hrefTmp.length-4));
but it’s still not working. Any suggestions?
April 23, 2018 at 3:31 am #945194Hi,
Thank you for the update.
Why are you trying to remove the hash in the url? Please try this solution instead.
// https://kriesi.at/support/topic/close-mobile-menu-by-clicking-on-active-navigation-item/#post-906654
The modification will force the mobile menu to close if an active menu item is clicked. It will not reload the page.
Best regards,
IsmaelAugust 13, 2020 at 10:43 am #1237328if it’s still useful try this:
add_action('wp_footer', 'remove_top_from_link_menu'); function remove_top_from_link_menu(){ ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery(".av-main-nav-wrap").on("click", function(){ if (jQuery.avia_utilities.isMobile) { var hrefTmp = jQuery("#av-burger-menu-ul .current_page_item a").attr("href"); jQuery("#av-burger-menu-ul .current_page_item a").attr("href", hrefTmp.substr(0, hrefTmp.length-4)); } }); }); </script> <?php }
- This reply was modified 4 years, 3 months ago by davidebord90.
August 13, 2020 at 2:38 pm #1237433Hi davidebord90,
Thank you for sharing! :)
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.