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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:01:53+00:00 2026-05-30T18:01:53+00:00

I have a link that loads dynamic content into a div… there need to

  • 0

I have a link that loads dynamic content into a div… there need to be a ton of additional ajax actions within that newly loaded dynamic content. Do I have to create a new delegate function for each of those actions in my success handler? (Does the delegate function, ideally belong in the success handler?) How can I consolidate these functions?

For example, I click the “view posts” button on the main screen. It loads in a bunch of posts into a modal window. Within that window, for example, there may be a ‘view comments’ button for each post, which makes its own ajax call and loads the comments directly into the modal window.

The two things I would like clarification on are what is the best practice for organizing these delegate functions. Secondly, when is delegate required/when is it not required?

Edit: Thanks guys. These were all great answers. I’m going to choose Ohgodwhy’s answer because he only has 245 rep.

  • 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-30T18:01:54+00:00Added an answer on May 30, 2026 at 6:01 pm

    There’s a great reference to the jQuery delegate function found in the jQuery documentation located at -> http://api.jquery.com/delegate/

    Delegate monitors a “parent” and applies a function that allows for a callback on all child elements, regardless if they’re dynamic or not.

    $("table").delegate("td", "click", function(){
      //All actions to be performed regardless if dynamic or not.
    });
    

    What’s important to note is that the delegate feature has since been replaced by the .on function in jQuery 1.7. You can monitor all DOM changes with the .on feature, which is also a replacement of the .live function.

    The proper syntax to monitor and ensure that functions are bound to all elements added on/after DOM load is ->

    $("table").on("click", "td", function(){
      //perform actions here for the click functions 
    });
    

    EDIT

    If you wanted to target all tag s with a class of “george” and ensure that the functions are run on all that are currently and will be in the future loaded, then you would do

    $(".modal_overlay").on("click", ".george", function(){
      alert('I have a class of George');
      //every item with a class of george when clicked will alert this.
    });
    

    This should make sense.

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

Sidebar

Related Questions

I have an AJAX link that currently loads a partial view into a div.
I have a page that loads dynamic content via ajax. When I scroll down
I have a small problem. So I have this page that loads dynamic content
I have a UIWebView that loads a link, http://www.google.com/a/datacommsales.net . But I want to
I have a page that dynamically loads content based on a user pushing a
I have an MVC masterpage set up which loads a dynamic menu using AJAX
I have a page which dynamically loads a section of content via AJAX. I'm
I have link with onclick=open_dialog which opens jquery ui dialog. It loads its content
Is it possible to have a link/button that will execute an AJAX/Jquery function to
I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make

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.