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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:00:44+00:00 2026-05-17T03:00:44+00:00

I hope you can help me with a problem; first, please don’t worry about

  • 0

I hope you can help me with a problem; first, please don’t worry about my language skills, I come from germany and I don’t speak english every day, unfortunately 🙁

I’m using jquery tabs in ajax mode and have some problems concerning click events. An example: I initalizate in my first and second tab such a click function on a button:

$(".new_message").live("click", function() { alert("test"); });

Now imagine following: a user clicks on the first tab and the button marked with class “new_message” is holding the defined click function. Up to here everything is fine, but on selecting the second tab, which has got the same button, there is a problem: javascript alerts two time “test”, but I only want to get it once. I searched a lot to solve this problem, all solutions I got were to use the live function, but i did so and it’s not working.

Is there a possibility to make this work, even in ajax tabs? Please note, that the javascript content of a tab was not loaded until it was selected. I’m not caching my tabs, so the content of the tab fires again and again (so if you click on tab 1, than tab 2 and again tab 1, the script alerts three times “test”)…

I hope you get it, whatever ;o)
Cheers, Bamboo

  • 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-17T03:00:45+00:00Added an answer on May 17, 2026 at 3:00 am

    You could simply check if the event is already bound, since it is a live binding:

    var bound = false; // this should exist on the containing page and not in each tab
    

    Then wire it up like so:

    $(function(){
        if (!bound)
        {
            $(".new_message").live("click", function() { alert("test"); });
            bound = true;
        }
    });
    

    I ran into a problem when using a wizard type ajax interface where the live() jQuery events would become bound, bound, and then rebound, as you navigated back and forth through the wizard. To ensure that any live events would be properly set you need to call the die() method first and then rebind.

    $("#myClickableThing").die("click").live("click", function () {
        // do work
    });
    

    And to add it as a new jQuery function you can try this:

    jQuery.fn.resurrect = function (eventType, callback) {
        $(this).die(eventType).live(eventType, callback);
    };
    

    Now you can call resurrect like this:

    $("#myClickableThing").resurrect("click", function() { 
        // do work
    });
    

    I wrote a blog post about exactly this issue and created a little helper function to handle it.

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

Sidebar

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.