Sorry, but you do not have the capability to view this topic
-
Supported
- Topics: 7
- Replies: 16
- Total posts: 23
Not too shy to talkPost count: 24Hi MAWK,
I am trying to hide a superfish sub-menu if a user clicks on any sub-menu item. The sub menu remains open by default after you click on it, which is not very user friendly, especially if the menu is a large one. The javascript code works only on the first page load, but not after an AJAX call. Do you know where I need to put the code for it to work after an AJAX call in the theme, or how I need to make that call?
Here’s the javascript, which works on the latest template version (http://www.aivahthemes.com/musicplay/) to hide the second sub-menu after you click on any one of the items in it. If you put this code towards the end in footer.php (just for testing purposes), it will work. But it won’t work after navigating to a different page after an AJAX callback.
<script type=”text/javascript>
(function($){
var mql=window.matchMedia(“screen and (min-width: 777px)”);
if(mql.matches){
var mymenu=$(‘#atp_menu’).superfish({});
$(‘.sub-menu’).on(‘click’,function(){
$(‘#atp_menu’).children(‘li:nth-child(2)’).superfish(‘hide’);
});}
})(jQuery);
</script>
Your help would be appreciated.
Thanks.