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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:23:57+00:00 2026-06-03T00:23:57+00:00

As we all know, since jQuery 1.7: $(‘someSelector’).live(‘click’, fn()); has become, essentially: $(document).on(‘click’, ‘someSelector’,

  • 0

As we all know, since jQuery 1.7:

$('someSelector').live('click', fn());

has become, essentially:

$(document).on('click', 'someSelector', fn());

All live events aren’t directly bound to the elements in the selector, but delegate bound to the document.

This, I assume, is because elements that would match 'someSelector' in the future, aren’t present in the DOM, so can’t have event handlers bound (via direct or delegate binding).

For single page applications where the vast majority, if not all elements are dynamically loaded, are there published guidelines about how best to handle the issue of performance with binding everything to the document?

Covering, for instance, the best way to register/re-register event handlers when new content is loaded via ajax() and how to update code written in the lazy .live() mindset?

  • 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-03T00:24:00+00:00Added an answer on June 3, 2026 at 12:24 am

    I’m not sure whether there are “published guidelines”.

    I think this approach has its merits:

    • Find the closest logical common ancestor that will not be deleted from the document.

      Example: For draggable table row behavior, this would be the parent table (or tbody).

    • Bind events there. This allows you to have separate instances of the same thing behave differently without the need for a context check.

      Example: If row-dragging is disabled temporarily on one of your tables, the table that handles the event would know, naturally. The document would not.

    • It would keep the number of events that are handled by document at a minimum, so there would not be many “is this really necessary” checks when an event occurs.

      Example: If there currently is no table with draggable rows, there is no need that an event handler even fires at the document level (just to find out that table.draggable tr wasn’t really the source of the event and dismiss it immediately).

    • If the common ancestor gets removed frequently, you can decide whether re-binding the event handlers upon its creation or binding them a few levels up in the hierarchy would be better.

    I would re-bind container events upon container creation, but that’s personal preference, I presume. Re-binding is easy enough, after all:

    // once, beforehand
    var draggableTableRowBehavior = {
      dragstart: function () { /* ... */ },
      dragstop: function () { /* ... */ }
      /* ... */
    };
    
    //in Ajax success:
    $table.on(draggableTableRowBehavior, 'tr');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We all know that a hash table has O(1) time for both inserts and
you all know: right click -> zoom in or out in flash file, well,
We all know that CSS sprite images are great to reduce the amount of
We all know the effects that lots of thrown exceptions can have over the
We all know about Boost . What other free C++ libraries are worth using?
We all know it - this is the reading that lists the changes brought
We all know to set canvas's context property like this: ctx.textBaseline = top; ctx.shadowColor
We all know that most applications out there assume class names to follow the
We all know about techniques to prevent db deadlocks - acquire locks in the
As we all know,we can use such api as LockWorkStation() in user32.dll to lock

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.