Solved

TreeView not working inside accordion menu

Posted on 2013-02-04
2
932 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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…

773 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