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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:19:29+00:00 2026-05-13T14:19:29+00:00

is it possible that javascript doesnt apply to elements created trough an ajax request?

  • 0

is it possible that javascript doesnt apply to elements created trough an ajax request?
practically i have a tree of elements like parents and children with a dept of more levels.

i have the root elements on the index page and on click i can retrive the children trough this request:

var get_children = function() {
 pid = $(this).attr("id");
 //var parentid = pid
    // store value in data variable
    var data = { par: pid };
    $.getJSON("/holz/children/",data,
        function(data){
      //remove the box if it already exists
      $("#parid-" + pid ).remove();
            // Add the messages div to the container
            $("#container").append("<div class='box' id='parid-" + pid + "'></div>");
            //create the id set for the box
            boxid = "#parid-"+pid
            //insert the elements one after each other with the id set to the elements pk  
            $.each(data, function(i,item){
                $(boxid).append('<p><a '+'id="'+item.pk+'"'+' class="element" href="#">'+item.fields.title +' ( id = '+ item.pk+' )'+'</a>'+'</p>');
            });
        }
    );
  return false;
};

the problem is that i cant go deeper because the request doenst apply on the elements i got from the first request. the ajax request calls a django view which should (and it does in the on the first element) and returns a json reponse which i use to create a box with the children.

what am i doing wrong?

thx

  • 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-13T14:19:30+00:00Added an answer on May 13, 2026 at 2:19 pm

    I’m not sure I fully understand but it sounds like you want an onclick eventhandler to apply to all domelements with a certain css class .element. Am I right?

    If so then just use jQuery’s live() event binder syntax. This will allow you to bind an event to all dom elements that match a given selector now, and in the future.

    To use some of your own code as an example:

    $('div.box').live('click', function() {
        alert('you clicked me!');
    });
    
    $("#container").append("<div class='box' id='parid-" + 1 + "'></div>");
    

    In the example above the div that we added dynamically will have our click event bound to it since we used the jquery api to insert it.

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

Sidebar

Ask A Question

Stats

  • Questions 525k
  • Answers 525k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you say there is no corresponding GRANT, what exactly… May 16, 2026 at 10:09 pm
  • Editorial Team
    Editorial Team added an answer It appears you are having a conflict. A simple solution… May 16, 2026 at 10:09 pm
  • Editorial Team
    Editorial Team added an answer You could have a helper method load your js and… May 16, 2026 at 10:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Is it possible to subclass and inherit from javascript Arrays? I'd like to have
I have a form field (a series of checkboxes) that's being created dynamically from
Is it possible to style a collapsed header in ExtJS so that it doesn't
I am trying to build some sort of a javascript antivirus that would try
I am building a web application that uses a lot of Javascript. Now I
Is it possible to override the html naming of fields in TabularInline admin forms
In JavaScript, it doesn't seem to matter whether you use single quotes or double
So basically I want to add a javascript function to a button's Click event
One of my website's users is experiencing Javascript problems with his IE8/WinXP setup, with
I am currently trying to implement this into my current code: http://cubiq.org/iscroll I have

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.