Skip to content

Instantly share code, notes, and snippets.

@fazen
Last active November 15, 2019 07:10
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fazen/0f7685e5079450b0da024a5d24b63b54 to your computer and use it in GitHub Desktop.
Save fazen/0f7685e5079450b0da024a5d24b63b54 to your computer and use it in GitHub Desktop.
  1. Add class always-visitable to parent items you want to be visitable;

  2. Add this js code after the row if ( $(this).is(top_level_link) ) { :

if ($(this).parent().hasClass('always-visitable')) {
  $('<a class="hover-link"></div>')
    .attr('href', $(this).attr('href'))
    .on('click', function(e){ e.stopPropagation(); })
    .appendTo($(this));
}
  1. Add this css:
#main-header .et_mobile_menu .always-visitable {
  position: relative;
  /* this li is clickable. change ui accordingly! */
}
#main-header .et_mobile_menu .always-visitable .hover-link {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  /* leave some space so right area works. you decide how much */
  right: 60px;

  /* for debugging — delete */
  background-color: #ff0;
  opacity: 0.3;
}
@csgaraglino
Copy link

I figured it out. I just remove the line:

if ( $(this).is(top_level_link) ) {$(this).attr('href', '#');}

@markdix-zimbo
Copy link

Hi @fazen and @csgaraglino

Do you have an issue of automatic re-direction after a few seconds when selecting the parent item i.e. when the sub menu items are expanded after a few seconds you are re-directed to the parent page if nothing is selected?

If you have any ideas of stopping the automatic re-direction I would be most grateful.

Thanks Mark

@nosekja
Copy link

nosekja commented Jun 11, 2017

Hi @fazen

I found your code on the elegantthemes page. it works great with my divi page for mobile menu. Is there a way to integrate this feature for top tier menu items on desktop menu? Not only mobile?

Thank you.

@seona13
Copy link

seona13 commented Nov 29, 2018

You, my friend @fazen, are an absolute star! Thank you for improving my reputation with the marketing department. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment