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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:32:34+00:00 2026-06-11T07:32:34+00:00

Im using .load() to populate a div with new content but when I do

  • 0

Im using .load() to populate a div with new content but when I do I have to recall all my scripts in order to use them inside the new content I beieve this is whats causing my event handlers to fire twice.

Am I wrong about that? If not is there an alternative method?

    $('.user').click(function(){
    if ($section !== 'users'){
        $section = 'users';
        $('div#contentWrapper').fadeOut(0).empty();
        $('div#contentWrapper').load('pages/users.html').fadeIn(500);
    }
    else{
        return;
    }

this is the code thats apparently firing twice.

    $('.addUser').click(function(){        
    $('.userPanel').fadeOut(0).empty();
    $('.userPanel').load('pages/addUser.html').fadeIn(500);
    });

I had initialy thought it was the fadeout that caused it so I set it to instant but that didnt resolve the issue. Another post on the site had recomended unbinding the click handler first but as I understand it this is a work around not a fix, and id rather fix the problem.

I am new to jquery and would really appreciate any help you guys can offer.

  • 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-11T07:32:36+00:00Added an answer on June 11, 2026 at 7:32 am

    When you load elements dynamically, you need to use jQuery’s .on() function to bind events to the elements that are loaded. You need to bind with .on() to an element that already exists in the DOM and usually the worst case scenario for that is the body element. If you be more specific than body you’ll usually get improved performance.

    For example, if you loaded a table row into a table and wanted to bind the click event on the new row, you’d use:

    $("table").on("click", "tr", function(event){
        //do something
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Ajax to dynamically populate a DIV. I have each page content stored
im using .load to load content into a div, i would then like to
I'm using the jQuery .load() function to pull in data to populate a div
I'm using $('#container_div').load(url) to populate a div via ajax. I would like to animate
When using jQuery.load to dynamically load HTML content into a webpage, what is the
I have a page in which I have a div. The content from that
I populate many parts of my website using $(#theDivToPopulate).load(/some/api/call.php, callBackToBindClickEventsToNewDiv); Where /some/api/call.php returns a
Hi i'm using this code to fetch new images from a folder to populate
I am currently using Google Charts with PHP to populate the data but the
When using LOAD DATA INFILE, is there a way to get the same functionality

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.