Note that there are some explanatory texts on larger screens.

plurals
  1. POJQUERY Two Clicks Issue
    primarykey
    data
    text
    <p>I'm currently having some issues with my menu, its pretty basic as per the requirements.</p> <p><strong>ISSUE:</strong></p> <p>A user can click on the menu button once and open the sub menu, the user then clicks on the next button opening that sub menu, this is repeated as per the number of menu options. Once the user has clicked through them, if the user were to click another menu button once, it will not open, if the user clicks it a second time it will open. So after one run through the menu will only respond to two user clicks rather than a single one. This problem is occuring in other areas.</p> <p>I suspect its something to do with my click handlers and event bubbling but my JQuery knowledge is self taught so I could do with a couple of pointers:</p> <p><strong>JQuery Code</strong></p> <pre><code>$(document).ready(function(){ $('#menu span').hide(); $('#menu li').not('.sub_menu').toggle(function(){ //$('#menu span').hide(); $('.open').hide(); //$(this).next().not('#mm_choice, .sub_menu').show(); $(this).nextUntil('li').not('#mm_choice, .sub_menu').show().addClass('open'); }, function(){ //$(this).next().not('#mm_choice, .sub_menu').hide(); //$(this).nextUntil('li').not('#mm_choice, .sub_menu').hide().removeClass('open'); $('.open').removeClass('open').hide(); }); }); </code></pre> <p><strong>HTML SOURCE CODE</strong></p> <pre><code>&lt;div id="menu" title="Main Menu"&gt; &lt;ul id="m_choices" class="main_menu"&gt; &lt;li id="mm_choice" title="Customer Segmentation Menu"&gt;Customer Segmentation&lt;/li&gt; &lt;span id="c_seg"&gt;&lt;li class="sub_menu" title="Cust Seg Menu1"&gt;Cust Seg Menu1&lt;/li&gt;&lt;li id="c_seg" class="sub_menu" title="Cust Seg Menu2"&gt;Cust Seg Menu2&lt;/li&gt;&lt;li id="c_seg" class="sub_menu" title="Cust Seg Menu3"&gt;Cust Seg Menu3&lt;/li&gt;&lt;/span&gt; &lt;li id="mm_choice" title="Industry Menu"&gt;Industry Selection&lt;/li&gt; &lt;span id="all_ind"&gt;&lt;li class="sub_menu" title="View All Industries"&gt;View All&lt;/li&gt;&lt;/span&gt; &lt;span id="spec_ind"&gt;&lt;li class="sub_menu" title="View information on a specific Industry"&gt;View Specific Industry&lt;/li&gt;&lt;/span&gt; &lt;li id="mm_choice" title="Customer Satisfaction Menu"&gt;Customer Satisfaction&lt;/li&gt; &lt;span id="all_cs"&gt;&lt;li class="sub_menu" title="View every industry's CS survey results"&gt;View All&lt;/li&gt;&lt;/span&gt; &lt;span id="spec_cs"&gt;&lt;li class="sub_menu" title="View a specific industry's CS survey results"&gt;View Specific Industry&lt;/li&gt;&lt;/span&gt; &lt;li id="mm_choice" title="Performance Measures Menu"&gt;Performance Measures&lt;/li&gt; &lt;span id="all_pm"&gt;&lt;li class="sub_menu" title="Trend Menu"&gt;View All&lt;/li&gt;&lt;/span&gt; &lt;span id="spec_pm"&gt;&lt;li class="sub_menu" title="Trend Menu"&gt;View Specific Industry&lt;/li&gt;&lt;/span&gt; &lt;li id="mm_choice" title="Business Performance Menu"&gt;Business Performance&lt;/li&gt; &lt;span id="all_bp"&gt;&lt;li class="sub_menu" title="Bus Perf Menu"&gt;View All&lt;/li&gt;&lt;/span&gt; &lt;span id="spec_bp"&gt;&lt;li class="sub_menu" title="Bus Perf Menu"&gt;View Specific Industry&lt;/li&gt;&lt;/span&gt; &lt;li id="mm_choice" title="Trend Analysis Menu"&gt;Trend Analysis Menu&lt;/li&gt; &lt;span id="all_trends"&gt;&lt;li class="sub_menu" title="Trend Menu"&gt;View All&lt;/li&gt;&lt;/span&gt; &lt;span id="spec_trends"&gt;&lt;li class="sub_menu" title="Trend Menu"&gt;View Specific Industry Trends&lt;/li&gt;&lt;/span&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>The menu.php file (html mark up) is imported (using php include();) into the index.php file. The JQuery file is imported in declerations.php, imported into index.php in the header. Declerations.php contains all necessary JQuery libraries. Intention is to add UI animation at a later stage so the .show() and .hide() methods will be elaborated upon.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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