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 6775465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:54:35+00:00 2026-05-26T15:54:35+00:00

My jQuery Code is as follows: $(‘.sidebar_options_arrow’).click(function() { id = $(this).attr(‘rel’); toggled = 0;

  • 0

My jQuery Code is as follows:

$('.sidebar_options_arrow').click(function() {
    id = $(this).attr('rel');
    toggled = 0;
    if(toggled == 0) {
        toggled = 1;
        $('#'+id+'-info').slideToggle('fast', function() {
            alert('1');
            toggled = 0;
        });
        $('.chat_sidebar_desc').not($('#'+id+'-info')).slideUp('fast');
    }
    return false;
});
$('#chat_sidebar ul li').click(function() {
    id2 = $(this).attr('rel');
    if(loading == 0) {
        loading = 1;
        $('#chat_main_container').fadeOut(function() {
            $('#loading').fadeIn(function() {
                if(id2 == 0) {
                    $('#chat_main_container').empty().load('chat/start.php');
                    $('#loading').delay(500).fadeOut(function() {
                        loading = 0;
                        $('#chat_main_container').fadeIn();
                    });
                }else{
                    $('#chat_main_container').empty().load('chat/index.php?roomid='+id2);
                    $('#loading').delay(500).fadeOut(function() {
                        loading = 0;
                        $('#chat_main_container').fadeIn();
                    });
                }
            });
        });
    }
    return false;
});

The issue I’m having is as follows:

  • I click sidebar_options_arrow and it works fine and slideToggle’s my element.

  • I then click an li on the same page and let it load a page.

  • I click sidebar_options_arrow again and it toggles twice, one after another. E.g. in this example, it would toggle it to show the element then toggle it to hide it.

  • If I then click another li on the page, and then click the sidebar_options_arrow again, it will toggle 3 times. It’s an ongoing pattern, I’ve tested it to 10 toggled and confirmed it by making it alert something whenever it toggles.

I would really appreciate any help I can get on this, it’s extremely annoying!

Thanks in advance.

  • 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-26T15:54:36+00:00Added an answer on May 26, 2026 at 3:54 pm

    It’s very likely that your code above is running multiple times, probably from the AJAX load, meaning the $('.sidebar_options_arrow').click() code is getting an additional handler each time you do load. To see this in action, simply add an alert("binding"); above your first line: $('.sidebar_options_arrow').click(function() {.

    The AJAX loaded content should not re-run handlers unless it needs to, as you see in this case it’ll cause some unwanted duplicate/overlapping behavior because of each load adding a new set of the same handlers.

    You’ll want to move the JS portion out of the content you’re loading so it doesn’t re-run, or prevent it another way. In the worst case (I recommend it not running at all, as that’s cheaper, but if you have to….) you can simply call .unbind() before .click() when attaching the handler. Note: if you have multiple handlers (potential user scripts, etc…anything here), you’ll need to name that function and call .unbind("click", functionName) explicitly to be safe.

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

Sidebar

Related Questions

I have some JQuery Code as follows: $(#sh-zone-button-cart-menu).live(click, function(event) { event.preventDefault(); $(#sh-zone-cart-menu).toggle(0, function(){ if($(this).is(:visible)){
I have a jQuery code as follows; $(#+iframeId).attr(src,url); //works perfect $(a[target=+iframeId+]).attr(href, url); //does not
I have 3 different jquery uses & put it into one code as follows:
My jQuery code: $(document).ready(function() { chrome.extension.sendRequest({get: height}, function(response) { height = response.value; }); $(#id).css(height,
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have some jQuery code. I have called an Ajax function file, file.php, that
I have this jQuery code that queries an API on a keyup event (via
My jQuery code (using ajax) request's data from a local php script (pgiproxy.php). This
I am referencing JavaScript as follows on an HTML page: <script type=text/javascript src=http://code.jquery.com/jquery-1.6.1.min.js></script> <script
I have a jQuery code as follows; var favorites = $(#favorites); var favoritesFooter =

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.