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

  • Home
  • SEARCH
  • 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 701223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:35:09+00:00 2026-05-14T03:35:09+00:00

I am not able to create a jsTree inside of a jQuery UI tab.

  • 0

I am not able to create a jsTree inside of a jQuery UI tab. If I create the jsTree outside of the tab, it works fine. Does anybody know if jsTree is incompatible with jQuery UI tab?

My page is below. If I replace the following line

var treeContainer = jQuery("#tabTree");

with:

var treeContainer = jQuery("#pageTree");

Then the tree loads fine in the page underneath the tab control.

<body>
    <div id="myTabs">
        <ul>
            <li><a href="tab1.html">Tab 1</a></li>
            <li><a href="tab2.html">Tab 2</a></li>
            <li><a href="tab3.html">Tab 3</a></li>
        </ul>
    </div>

    <div id="pageTree"></div>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js" type="text/javascript"></script>         
    <script type="text/javascript" src="jsTree/jquery.tree.js"></script>
    <script type="text/javascript">     
        $(function(){

            $("#myTabs").tabs();

            var treeContainer = jQuery("#tabTree");
            var treeData = {
                data: {
                    type : "json",
                    opts : {
                        static : [
                            {
                                data: "A node",
                                children: [
                                    { data : "Child node 1" },
                                    { data : "Child node 2" },
                                    { data : "Child node 3" }
                                ]
                            }
                        ]

                    }
                }
            };
            treeContainer.tree(treeData);
        });     
    </script>
</body>

Here are the contents of tab3.html:

<div id="tab3Container">        
    <div id="tabTree"></div>
</div>
  • 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-14T03:35:09+00:00Added an answer on May 14, 2026 at 3:35 am

    The content in those tabs isn’t present until you click the tab to load it, so the selector jQuery("#tabTree") doesn’t have anything to match, no elements matching that selector exist yet. You need to run this code when that ajax page is loaded, like this:

    var treeLoaded = false;
    $("#myTabs").bind( "tabsload", function(event, ui) {
      if(!treeLoaded && jQuery("#tabTree", ui.panel).length) {
        var treeContainer = jQuery("#tabTree");
        var treeData = {
            data: {
                type : "json",
                opts : {
                    static : [
                        {
                            data: "A node",
                            children: [
                                { data : "Child node 1" },
                                { data : "Child node 2" },
                                { data : "Child node 3" }
                            ]
                        }
                    ]
    
                }
            }
        };
        treeContainer.tree(treeData);
        treeLoaded = true;
      }
    });
    

    The tabsload event, described here, runs when ajax content is loaded. The code above checks if your id="tabTree" was in that loaded content, and if so and the tree hasn’t been built yet, builds it.

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

Sidebar

Related Questions

I have done jQuery and Ajax, but I am not able to get the
I am not able to create minidump form my process by changing system setting.
I am not able to create EJB 2.1 beans using a wizard in the
I am not able to create a Firefox cookie with following line: setcookie(TestCookie, $value,
In my windows 2003 box, I am not able to create new web applications.
I am not able to create database columns when i use t.string or t.number.
In my bllLanguage.cs class I am not able to create dalLanguage class's objects and
I am new to glui. I am not able to create glui menubar. Whenever
We are not able to create the installer after migrating the code from VS2005
I am not able to access localhost https pages in firefox3. It gave the

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.