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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:14:24+00:00 2026-05-22T20:14:24+00:00

My question first. How to make buttons ‘inside jsTree’ work? It worked with onclick

  • 0

My question first. How to make buttons ‘inside jsTree’ work? It worked with onclick defined.

But now I used a jQuery handler for a click on buttons. Works fine. See sample http://jsfiddle.net/radek/5xym7/4/

I copied the handler definition (below) to my existing code (bit big to copy it here & not sure which part I need to provide to debug the issue)

$('button[type=button]').click(function(){
    var params = $(this).val();
    document.getElementById("results").innerHTML+="<BR>"+params.split('|')[0]+" - "+ params.split('|')[1]+" - "+ $(this).next().prop('checked');

});

how the page look like

how the page look like

But it doesn’t work for buttons that are inside jsTree, On the other hand buttons outside <div id='jstree'></div> work with my handler.

html for buttons inside jsTree

<button value="login|basic" class="run square_button button_background" type="button"> run </button>
<input name="restore" title="restore before ant run" type="checkbox">

html for buttons outside jsTree

    <button class='run square_button button_background button' id='search' type='button' value='Search'>
      Search
    </button>
  • 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-22T20:14:25+00:00Added an answer on May 22, 2026 at 8:14 pm

    In your example, you bind to the click event from $(document).ready(), but initialize your jsTree object outside the $(document).ready() function. The jsTree creating block will execute as soon as that part of the source is loaded, while the $(document).ready() will execute later, upon the whole DOM is loaded. So essentially the jsTree contained buttons do not exist yet, when you try to bind to their click event.

    Two easy ways to remedy this:

    • use jQuery’s live() function to allow binding of dinamically created DOM nodes
    • reorganize your code, so the jsTree initialization also takes place in your $(document).ready(), and bind to the click event after the jsTree is created

    I did the latter to your fiddle, it seems to work fine now. http://jsfiddle.net/5xym7/6/

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

Sidebar

Related Questions

Real Dumb question. I figured I would have gotten this straight by now, but
there is a similar question in here but for some reason I cannot make
This is a two-part question: First, I am interested to know what the best
first question here. I'm developing a program in C# (.NET 3.5) that displays files
First question on here so please be nice :) I know very little about
First question on Stackoverflow (.Net 2.0): So I am trying to return an XML
My first question =). I'm writing a video game with a user interface written
First question here: it is a very short yet fundamental thing in Java that
First question from me; I'm currently fixing a graphing service that uses XSLFO to
First question is, given a url to an mp4 video, how can I save

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.