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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:34:15+00:00 2026-05-20T10:34:15+00:00

I am having some trouble with jquery’s live and die methods. http://jsfiddle.net/fC5Nr/4/ //bind above

  • 0

I am having some trouble with jquery’s live and die methods.

http://jsfiddle.net/fC5Nr/4/

//bind above function to clicking a
$('a').live('click', functionThatWaitsFiveSeconds)

I need to attach an event handler to clicking a link – and I want to unbind the handler while the function is running to prevent the function running over and over before it is complete (function is performing a ajax request then handling the response.

I can do all of the above just fine.

However, because the above handler is attached to a (a) tag I need to return false (to prevent the link from being followed). To do this I need to bind a different function to handle clicks and return false.

I need to know how to unbind my complicated function – while keeping my simple (return false) bound at all times.

The above fiddle should work, but after unbinding the event handler, it doesn’t bind again? I’ve tried a few combinations of namespacing etc but cannot get this together.

  • 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-20T10:34:16+00:00Added an answer on May 20, 2026 at 10:34 am

    Update got it working

       function denyRest() {
            $("body").append("<h1>return false</h1>");
            return false;
        }
        function functionThatWaitsFiveSeconds() {
            $('a').die('click.thing', functionThatWaitsFiveSeconds);
            var loader = $('<div class="loader">doing some stuff</div>');
            $('#content').append(loader);
            loader.animate({
                'width': '500'
            }, 5000, function() {
                loader.remove();
                $('a').die('click.otherthing', denyRest).live('click.thing', functionThatWaitsFiveSeconds).live('click.otherthing', denyRest);
            });
        }
    
        $('a').live('click.thing', functionThatWaitsFiveSeconds);
        $('a').live('click.otherthing', denyRest);
    

    Updated fiddle.

    I believe The issue was this.

    1. Use live to attach the handler to wait 5 seconds
    2. Use live to attach a handler that returns false to stop events.
    3. Click anchor tag, which removes the wait 5 second handler.
    4. Clicks to the anchor tag at this time will be stopped via the return false statement.
    5. NOW the return false statement is first. Once we rebind the wait 5 seconds handler it is in second place to be ran but gets denied by the return false handler.
    6. Fixed this to trash both handlers and rebind them in the correct order.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having some trouble with jQuery's slideToggle function in IE8 for some reason the
I'm having some trouble writing a jQuery function and could use a little help.
I'm having some trouble with the jQuery hover method. Here's the relevant JavaScript code:
I'm having some trouble getting my head around the jquery queue method. I've got
I'm having some trouble getting binding to work with JQuery. <iframe id=wufooFormz7x3k1 height=281 allowtransparency=true
I'm having some trouble with finding the visibility param for JQuery. Basically... the code
I am having some trouble setting up FancyBox, I am somewhat new to jQuery.
I'm very new to JQuery, and I'm having some trouble understanding how to do
I'm having trouble getting some javascript and Jquery to delay the appropriate amount of
Using jQuery 1.7 I'm having trouble binding a Click event to some dynamically loaded

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.