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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:15:48+00:00 2026-05-22T19:15:48+00:00

I’m pulling my hair out trying to resolve this so any tips and help

  • 0

I’m pulling my hair out trying to resolve this so any tips and help would be great.

I’m trying to build a visual logic tree where the user will be able to input each node of the actual logic tree (this is a screen shot of what it actually looks like). The default logic tree has a user input for hypothesis, then 4 user inputs for “buckets” which branch out from the hypothesis and then each bucket has 3 default “sub-buckets.”

Aside from entering input to each node, a user can do two things:
1) a user can create additional “buckets” (above and beyond the 4 default ones)
2) a user can create additional “sub-buckets” for each bucket

The code I have successfully 1) allows a user to create new “buckets” 2) allows a user to create new “sub-buckets” for any of the 4 default buckets that exist.

However, my problem is that this code breaks when a user attempts to add a new “sub-bucket” to a “bucket” they just created. I can’t figure out why this is happening.

Here is the JS for adding a bucket and adding a sub-bucket:

    $('.add_sub_bucket').click(function (){
        // determine what sub-bucket link was clicked
        var currentId = $(this).attr('id');
        $('#bucket_rows' + currentId).append('<tr><td class="td_test"></td><td class="td_test"></td><td class="td_test"><input type="text" placeholder="sub-bucket" name="sb' + currentId + '[]" /><a href="#" class="remove_sub_bucket">' + currentId + '<img src="/images/xbutton.png" /></a></td></tr>');
    return false;
    });

    var count_bucket = 3; //default # of buckets is 4 (numbers 0 through 3)
    var loadPHP = "create_new_bucket.php";  
    $(".add_bucket").click(function(){
        count_bucket++;
        $("#tree_container2").append( $('<div id="bucket' + count_bucket + '">').load(loadPHP, {count_bucket: count_bucket}));
        return false;
    });

Here is the PHP script that is called by JS to create a new bucket:

<?php
    include_once "test_functions.php"; // include functions page
    $i = $_POST['count_bucket'];
    $_SESSION['buckets'] = $i;
    drawBucketNew($i);
?>

Here is the drawBucketNew function in PHP that adds a “bucket” to the logic tree the user has on screen:

function drawBucketNew($i)
{
echo $i; //doublecheck the bucket count is correct
        echo '<div id="bucket_rows' . $i . '">';
            echo '<table class="basic">';
                echo '<tr>';
                    echo '<td class="td_alt">' . '</td>';
                    echo '<td class="td_alt">' . '</td>';
                    echo '<td class="td_alt"><input type="text" placeholder="sub-bucket" name="sb' . $i . '[]" /></td>';
                echo '</tr>';

                echo '<tr>';
                    echo '<td class="td_alt">' . '</td>';
                    echo '<td class="td_alt"><input type="text" placeholder="bucket" name="b[]" /><a href="#" id="remove_bucket">remo</a></td>';
                    echo '<td class="td_alt"><input type="text" placeholder="sub-bucket" name="sb' . $i . '[]" /></td>';
                echo '</tr>';

                echo '<tr>';
                    echo '<td class="td_alt">' . '</td>';
                    echo '<td class="td_alt">' . '</td>';
                    echo '<td class="td_alt"><input type="text" placeholder="sub-bucket" name="sb' . $i . '[]" /></td>';
                echo '</tr>';
            echo '</table>';

        echo '</div>'; // close bunch rows

                echo '<table class="basic">';
                    echo '<tr>';
                        echo '<td class="td_alt"></td>';
                        echo '<td class="td_alt"></td>';
                        echo '<td><a href="#" class="add_sub_bucket" id="' . $i . '">add sub-bucket</a></td>';
                    echo '</tr>';
                echo '</table>';
}
  • 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-22T19:15:49+00:00Added an answer on May 22, 2026 at 7:15 pm

    You should use jQuery’s live() method for the click event like so:

    $('.add_sub_bucket').live("click",function (){ //...

    This will delegate the click event handler on new elements as they are added to the DOM as stated below:

    The live() method is able to affect elements that have not yet been added to the DOM through the use of event delegation: a handler bound to an ancestor element is responsible for events that are triggered on its descendants. The handler passed to .live() is never bound to an element; instead, live() binds a special handler to the root of the DOM tree…

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.