Solved

TreeView not working inside accordion menu

Posted on 2013-02-04
2
924 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
  • 2
2 Comments
 
LVL 7

Accepted Solution

by:
Element1910 earned 500 total points
Comment Utility
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
Comment Utility
And here's a image of what it looks like (see attached).
AccordianTreeview.JPG
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now