Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery superfish - onhide event firing too quickly
    primarykey
    data
    text
    <p>I'm using superfish (<a href="http://users.tpg.com.au/j_birch/plugins/superfish/#aa" rel="nofollow">http://users.tpg.com.au/j_birch/plugins/superfish/#aa</a>) with jquery to do menu control. Nearly all the elements are set up in <li> elements nested in . I have one menu item I want to hide every time the superfish menu closes (I show it elsewhere with .show() ). So, my superfish initialization looks like this: </p> <pre><code>$(document).ready(function () { $("#menu").superfish({ delay: 400, onHide: function () { $("#HideThis").hide(); } }); }); </code></pre> <p>However, it instead hides HideThis on hover over of HideThis (no hover event is bound to that element). This makes the menu item unusuable, since it hides when you try to click it instead of when the menu closes. There doesn't appear to be any other events that could fit my purposes, any ideas how to make this work through superfish?</p> <p>The HTML i'm using looks like this:</p> <pre><code>&lt;ul id="menu"&gt; &lt;li id="Stuff"&gt;&lt;span&gt;Stuff&lt;/span&gt; &lt;ul&gt; &lt;li id="HideThis" &gt;&lt;span&gt;Hide This&lt;/span&gt; &lt;ul&gt; &lt;li&gt;&lt;span&gt;Hidden Stuff&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="DontHideThis" &gt;&lt;span&gt;Dont Hide This&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Edit: I was able to find out the problem: the 'onHide' event triggers every time a submenu hides, not just when the whole menu hides (Fun fact, it also triggers when the menu first shows; so onHide occurs a lot more often than you would expect). So, I ended up having to filter onHide like so:</p> <pre><code>$(document).ready(function () { $("#menu").superfish({ delay: 400, onHide: function () { if ($('ul.sf-menu li.sfHover').length == 0) $("#HideThis").hide(); } }); }); </code></pre> <p>And the 'if' statement is only true when all menus are collapsed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload