Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:53:01+00:00 2026-06-15T23:53:01+00:00

Explanation I have searched around for this but was unable to find a solution

  • 0

Explanation

I have searched around for this but was unable to find a solution and/or advice for this specific problem.

I have a navigation menu with items that have drop down lists. These drop down lists are enabled when any one of the menu buttons with a drop down is clicked, thereafter the drop downs show/hide on hover. If anywhere else on the screen is clicked whilst the drop downs are enabled then they immediately get disabled and disappear.

Sorry for the poor explanation, that is the best way I can put it 🙁

I have produced a basic example here (the drop downs dont show, they just log in the console):

http://jsfiddle.net/VFJA3/4/

Please ignore all HTML and CSS, the easiest way to create this was to just pile all the code in, it is not relevant for this issue.

My Question

As you can see I have a property called MN.dropDownsOn. This property is a boolean to indicate whether or not the drop downs should show on mouseenter. The boolean is enabled/disabled when a menu item is clicked, or anything but is clicked…

What I would like to know is whether this can be achieved in a better way? I dont really like storing a global value to indicate whether the drop downs are enabled or not, but I cannot think of a better way of doing it. Any suggestions?

Thanks in Advance

For ease of access, here is my JS:

MN.dropDownsOn = false;

/**
 * Initialize the Drop Downs
 * Initialize the Drop Downs in the Navigation Menu
 */
MN.initializeDropDowns = initializeDropDowns;
function initializeDropDowns(){
    // THIS IS THE PART I AM UNSURE ABOUT
    $(document).on('click','.dropdown',function(e){
        // Enable all the drop downs
        MN.dropDownsOn = true;
        // Ensure this down is now visible
        $(this).trigger('mouseenter');
        // Stop jQuery from disabling the dropdowns
        e.stopPropagation();
    });
    $(document).click(function(){
        // Enable all the drop downs
        MN.dropDownsOn = false;
    });     
    // BELOW IS FINE, APART FROM THE MN.DROPDOWNSON MIGHT NEED TO GO
    // Set the hover functions
    $(document).on('mouseenter','.dropdown',function(){
        if(MN.dropDownsOn){
            // Show the dropdown    
        }
    });
    // Set the hover functions
    $(document).on('mouseleave','.dropdown',function(){
        if(MN.dropDownsOn){
            // Hide the dropdown    
        }
    });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:53:02+00:00Added an answer on June 15, 2026 at 11:53 pm

    As no other suggestions came through, I would put my comments as recommendations:

    1. Make dropDownsOn a local variable in function initializeDropDowns. This will be available to all the event handlers being registered in the function.

    2. Convert initializeDropDowns into a class and add the event handlers and dropDownsOn as member variables. The object constructed can be bound as data to $(document) and retrieved during event handling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched a lot of places but couldnt find a clean sequential explanation
I have searched for a good explanation but can't find one. I could try
I've searched around for a while but I can't find a concise explanation of
I have encountered this problem today and I don't have an explanation for it.
I've searched around for solutions to this problem, and the only answer I can
I have searched about difference between DNID and Extension. But I couldn't find any
Searched for answer for this but couldn't find anything. The closest I could find
I searched the whole internet but could not find any good explanation on how
I have searched high and low for documentation on this, but I just cannot
I have searched the site and found similiar topics, but my problem is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.