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

  • Home
  • SEARCH
  • 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 6795635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:22:14+00:00 2026-05-26T18:22:14+00:00

I have written a function which fires when a particular menu item is clicked.

  • 0

I have written a function which fires when a particular menu item is clicked. essentially the code replaces (by changing class to .activedock) a dock at the bottom of the page along with the name of said dock which is pulled from the (‘li’) in the menu which has been clicked. This is a little hard to articulate but hopefully this makes sense.

All of this is animated with the extended jquery-ui versions of addClass and removeClass to give the effect of the dock sliding off the bottom of the screen and the replacement selected dock being slid up into place. At the same time the dock name fades out, is replaced and the new name fades back into place.

This all works wonderfully, however the effect screws up if i select another menu item while the animation is still taking place. What a need to do is to modify the code below to simply queue the function if it is called again while the animation is still taking place. Alternatively, if this proves to complicated, I would be happy to just be able to prevent the function from being called again while it is still active.

Does anyone know how I would go about this.

function selectFilter($this) {


var $filtername = $this.text();
var $activedock = $('.activedock');
$selected_dock = $('#' + $filtername);
$name = $('#filter_name').find('h1');


if ( $filtername == $activedock.attr('id') ) {

return false;

}


var $filtertext = $filtername;      
        $activedock.removeClass('activedock', 1000);
                $name.fadeOut('1000', function() {

                    $selected_dock.addClass('activedock','1000');

                    $name.text($filtertext);
                    $name.fadeIn('1000', function() {

                    var $menuWidth = $('#filter_name').width();

                    $('#filter_menu').css('min-width', $menuWidth);


                    });
                });

}

P.S. I am relatively new to jQuery so my apologies if the code above is not using best practice etc…. I’m still learning.

Also the above function is called when the user clicks the menu item as shown in the code below:-

//Show filter menu

$(document).ready(function() {

$('#full-width-layout_c1_col-1-1_1').on( 'mouseenter mouseleave click', '#filter_name', function(event) {

var $menu = $('#filter_menu');
var $icon = $('#popupicon');


//Hover over Filter Name
if (event.type == 'mouseenter') {
                    $menu.addClass('menu_hovered_item');
                    $icon.show('fade', 200);
        }
        else if (event.type == 'mouseleave'){
                    $menu.removeClass('menu_hovered_item');
                    $icon.hide('fade', 200);
            }



//Open menu on click
        else if (event.type == 'click'){


            $menu.show('fade','slow');

//hover or click on menu item

                    $('#full-width-layout_c1_col-1-1_1').on( 'mouseenter mouseleave click', '#filter_menu li', function(event) {

                    var $menuItem = $(this);

                            if (event.type == 'mouseenter') {
                            $menuItem.addClass('menu_hovered_item');
                            }
                            else if (event.type == 'mouseleave'){
                            $menuItem.removeClass('menu_hovered_item');
                            }

                            else if (event.type == 'click'){
                            var $this = $(this);
                            selectFilter($this);
                            $menu.hide();
                            }

                    });

        }    

    });  
});
  • 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-05-26T18:22:15+00:00Added an answer on May 26, 2026 at 6:22 pm

    Detect Animation

    It is possible to detect whether the animation is still running for a specific element.

    The technique is detailed in this article.

    var wait = setInterval(function() {
        if( !$("#element1, #element2").is(":animated") ) {
            clearInterval(wait);
            // This piece of code will be executed
            // after element1 and element2 is complete.
        }
    }, 200);
    

    Prevent Animation Queue Builup

    Alternatively, you can slo prevent a animation queue byusing this technique.

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

Sidebar

Related Questions

I have written a simple jQuery.ajax function which loads a user control from the
I have written my own function, which in C would be declared like this,
I have a function written in C# which has one parameter type as Dictionary<string
I have written a function for a multilevel wordpress menu, but I'd like it
I have written a small function, which uses ElementTree and xpath to extract the
I have written a function which scans all the files/directory in a given directory
I have written a function which takes a whole bunch of files, zips them
I have a custom UI control which has a JavaScript class written around the
I have written a function that gets a given number of random records from
I have written a function that positions a tooltip just above a textbox. The

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.