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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:26:07+00:00 2026-06-01T13:26:07+00:00

I have a complicated nested form (Ryan Bates’ version) with .live() attached to some

  • 0

I have a complicated nested form (Ryan Bates’ version) with .live() attached to some of the dynamically generated elements, which I’m now transitioning over to .on() along with an upgrade from Jquery 1.4 to 1.7.

Here’s a sample of one of the ~22 changes:

# old version with .live()
$('.options .image').live('click', function(){
    console.log('clicked .options')
})

# new version with .on()
$('.options').on('click', '.image', function(){
    console.log('clicked .options')
})

The changes work perfectly well for the form elements that already exist but they are failing for any nested elements that are dynamically created afterwards. Hence, it’s working more like Jquery’s bind than live. Do you know what might be going on here?

Due to the exceeding complexity of the code and lots of partials I’m leaving it out for now (hoping you might have a hunch!). Thanks.

  • 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-01T13:26:09+00:00Added an answer on June 1, 2026 at 1:26 pm

    As per 3nigma’s comment but modified with your original selector, this will work:

    $(document).on('click', '.options .image', function() {
      console.log('clicked .options');
    });
    

    However, I don’t think setting document as listener is usually the way to go. In your original version with .live() you are selecting .image nodes within the .options node.

    But the question doesn’t say which parts are loaded dynamically. I suspect that .options is also part of the content that’s loaded dynamically. The first selector when using .on() for delegating listeners has to be something that is NOT destroyed:

    $('#someWrapper').on('click', '.options .image', function() {
      console.log('clicked .options');
    });
    

    #someWrapper doesn’t need to be a new wrapper element, it can be any ancestor (what some people call a “parent”… but that’s a misnomer since it can be a grandparent or great-grandparent or whatever!) that is not destroyed. The closer to the target selector (.options .image) the better.

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

Sidebar

Related Questions

I have a query which uses a complicated set of CASE statements, some nested,
I have a complicated MySQL query which takes a lot of time, selecting from
I have some complicated, problem to be solved. Now I need to write such
I have a project that has a fairly complicated, nested (references calling the referenced
I have a fairly complicated SQL query with a nested subquery. When I try
Here is the situation. I have some ViewModels that contain nested complex model types.
I have a complicated problem and I hope to explain it clearly possible... I
I have a complicated report that I need to draw with GDI+ (I don't
I have this complicated slider that utilizes tons of animation. I'm trying to find
I have a complicated problem, and I need help. I have a base case,

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.