Solved

TreeView not working inside accordion menu

Posted on 2013-02-04
2
939 Views
Last Modified: 2013-02-05
I have to create a menu with accordion and tree view.
But the problem i am facing is the tree view is not working in accordion menu

Please help me to resolve the problem.

Code is given below

<head>
  <meta charset="utf-8" />
  <title>jQuery UI Accordion - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
  <script type="text/javascript"
     src="${pageContext.request.contextPath}/resources/js/treeview/jquery.cookie.js"></script>
<script type="text/javascript"
   src="${pageContext.request.contextPath}/resources/js/treeview/jquery.treeview.js"></script>
 
 
<link rel="stylesheet"
      href="${pageContext.request.contextPath}/resources/css/jquery.treeview.css" />
 
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $("#black, #gray").treeview({
            control : "#treecontrol",
            persist : "cookie",
            cookieId : "treeview-black"
      });
 
  $(function() {
          $( "#accordion" ).accordion();
        });
       
  </script>
</head>
<body>
 
<div id="accordion">
  <h3>Heading</h3>
        <div>
         <ul id="black" class="treeview-black">
                              <ul>
                                    <li><span>Leve1</span>
                                          <ul>
                                                <li>Level2</li>
                                          </ul>
                                    </li>
                              </ul>
                        </ul>
     
        </div>
  <h3>Purchase</h3>
  <div>
    <p>
    Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
    purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
    velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
    suscipit faucibus urna.
    </p>
  </div>
 
</div>
 
</body>
</html>
0
Comment
Question by:Rocking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 7

Accepted Solution

by:
Element1910 earned 500 total points
ID: 38852000
Got it working for me by putting that jquery.treeview in it's own folder (directly from download), into the Scripts directory on my site directory, then changing the relative paths to the css/jquery. See page source below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Accordion - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
  <script src="Scripts/jquery.treeview/jquery.treeview.js" type="text/javascript"></script>
    <script src="Scripts/jquery.treeview/lib/jquery.cookie.js" type="text/javascript"></script>
  <link href="Scripts/jquery.treeview/jquery.treeview.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery.treeview/demo/demo.js" type="text/javascript"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script type="text/javascript">
      // fourth example
      $("#black, #gray").treeview({
          control: "#treecontrol",
          persist: "cookie",
          cookieId: "treeview-black"
      });

      $(document).ready(function () {
          $(function () {
              $("#accordion").accordion();
          });

      });
       
  </script>
</head>
<body>
 
<div id="accordion">
  <h3>Heading</h3>
        <div>
         <ul id="black" class="treeview-black">
                              <ul>
                                    <li><span>Leve1</span>
                                          <ul>
                                                <li>Level2</li>
                                          </ul>
                                    </li>
                              </ul>
                        </ul>
     
        </div>
  <h3>Purchase</h3>
  <div>
    <p>
    Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
    purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
    velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
    suscipit faucibus urna.
    </p>
  </div>
 
</div>
</body>
</html>

Open in new window

0
 
LVL 7

Expert Comment

by:Element1910
ID: 38852009
And here's a image of what it looks like (see attached).
AccordianTreeview.JPG
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JavaScript Sort Ordering and Choice Limiting 5 38
DTD and JAVA versions 1 33
Jquery 7 34
selected value 16 26
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question