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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:59:08+00:00 2026-05-15T08:59:08+00:00

Edit: changing .ready() call per Matt’s suggestion. I use jQuery to configure some stuff

  • 0

Edit: changing .ready() call per Matt’s suggestion.

I use jQuery to configure some stuff like so:

$(function ()
{
     $('.myThing').each(function() {

         ... configure it ...

     });
});

My problem is when a new element gets added to the DOM after .ready() has been called. The configuration is not performed on those elements.

For simple things like binding a click event, .live() gets the job done. But for more complicated stuff I have not found a good solution.

Is there an event for when the DOM changes? Or more particularly when new elements are added to the DOM?

Edited: Tentative solution using livequery seems to be:

$(function ()
{
    $.fn.configureIt = function()
    {
        ... configure it ...
    }
});
$('.myThing').livequery(function () {
    $(this).configureIt ()
});

Edited again: livequery turned out not to be the solution. It searches the DOM for added or removed elements often. On a reasonably fast computer, running a moderate page, this is fine. On a slow computer, with a very large page, several livequeries and IE6, it has half-second lag every few seconds and longer lag on page load.

We concluded that making a shared ‘common behaviors’ catered to our laziness. Since our team has some moderate JavaScript people and some next-to-no JavaScript people and no JavaScript gurus, we wanted to define conventions for HTML markup and not touch these behaviors with each new page. This proved to not be possible given our JavaScript knowledge at the time.

The solution we came up with was that whenever we change the DOM with AJAX or dynamic content creation, we would an event:

$('.stuff').load(loadUrl, postData, function() {
    $(this).trigger('contentLoaded');
    // among other stuff
});

And then for any widget type thing, we rely on this convention.

$('*').live('contentLoaded', function() {
    $('.myThing', this).configureIt();
});

It’s not ideal. Individual page makers need to know about the convention of triggering a custom event when they do things in their page (admittedly encapsulated in some shared utility functions) and widget makers need to rely on page makers using this convention, but in the end this is not that big of a problem since we work on a closed team and don’t publish our applications externally.

  • 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-15T08:59:09+00:00Added an answer on May 15, 2026 at 8:59 am

    I’ve used the livequery plugin for just that purpose. It works for me, but if it doesn’t in your case you might at least get some ideas of how it works from the source code.

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

Sidebar

Related Questions

Edit: Prepare my objects for the use within a HashMap. after reading a bit
I have a single-threaded linux app which I would like to make parallel. It
I am using jQuery-1.4.2 with CakePHP and a few days ago I had this
I pulled the latest version of three20 from github and installed their template. I
Check the following link in Chrome: http://www.bavarianblue.com/parts-list/?tags=struts The site is totally jacked in IE
I am using the Uploadify Plugin to upload the picture, and i am doing
Hello can somebody write or point to a good symfony plugin installation tutorial. Here
The user sees a form with many controls, including a list box. He selects
I am facing problem finding any solution for converting my PDF to HTMl/xml.This requirement
Reading this question , I wanted to test if I could demonstrate the non-atomicity

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.