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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:43:53+00:00 2026-06-10T11:43:53+00:00

Solution: Thanks to Shmiddty, I figured this out: $( static parent element ).on(‘submit’, ‘#add_client’,

  • 0

Solution:

Thanks to Shmiddty, I figured this out:

$( static parent element ).on('submit', '#add_client', function(e) {
    e.preventDefault();
    firm.addUser( $(this), '/ci/firm/add_client', 'client' );
});

Description:

I building some forms for a client. I want this form to be dynamically created depending on the link he clicks. This form is going to be auto-populated with some data.

Here is the jQuery that will create the dynamic content:

$('.create').on('click', function(e) {
    e.preventDefault();
    utility.create_modal(); // dynamic div with form
});

This is the function that creates the div and place the PHP form in the html:

$(document.createElement('div')).attr({
    'class' : 'span3'
}).html( create_div( '/ci/firm/return_user_form/client', 'html' ) ),

Here is the ajax function:

var result = '';
$.ajax({
    url: path, 
    type: 'get', 
     dataType: type,
     async : false,
     success: function(data) {
         result = data;
     } 
    });
return result;

This is the html that is pulled from the PHP file: (it’s a huge form, i’m just going to include the button in question)

<input type="submit" name="submit" value="Add Client"  id="add_client">

Problem:

This dynamic html content has a form in it. I want to place a JavaScript event ON the form that I included. Is this possible? If so, how can I do it?

This does not work (#add_client is the id of the button in the form):

$('#add_client').on('click', function(e) {
    e.preventDefault();
});
  • 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-10T11:43:55+00:00Added an answer on June 10, 2026 at 11:43 am
    $('some_parent_selector').on('click', '#add_client', function(e) {
        e.preventDefault();
    });
    

    The on listener needs a parent object (that is not dynamic) to listen for a click event that bubbles up. Then, when the event bubbles up to the parent, it determines whether or not it originated from '#add_client', and if it does, it calls your anonymous function.

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

Sidebar

Related Questions

Here is the Solution ,thanks Gustavo for the suggestion: class Program { static void
SOLUTION Thanks to casperOne's answer , here is my resulting function: Shared Function FormatDate(ByVal
Solution at end of this post. By default the time is set to one
Solution: strpos turned out to be the most efficient. Can be done with substr
Chosen Solution Thanks for the help everyone. I've decided to do the following. public
SOLUTION Thanks to 1111... vector<std::string> split_at_line(string str, int lines) { vector<std::string> nine_ln_strs; string temp;
(see my answer below for solution - thanks for the feedback) It's probably something
Solution: thanks to the suggestion from @Guarav I was inspired and FINALLY came up
I've searched online and this website alike for a simple and adaptable solution but
SOLUTION: Thanks to Patrick below, I have refactored the C# CodeProject version into a

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.