views:

784

answers:

3

Hello Everyone,

I want to use the jQuery accordion tool for a form i'm building so I used some sample code from the jquery website but it doesn't work at all!

The javascript does nothing at all so you just get the html rendered. I am using version 1.3.1 of jquery with version 1.6rc6 of jquery-ui.

<head runat="server">
    <script src="/scripts/jquery-1.3.1.js" type="text/javascript"></script>    
    <script src="/scripts/jquery-ui-personalized-1.6rc6" type="text/javascript"></script>
    <title>JQuery Test</title>
</head>
<body>

<div class="demo">

<div id="accordion">
    <div>
     <h3><a href="#">Section 1</a></h3>
     <div>
      <p>
      Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
      ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
      amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
      odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
      </p>
     </div>
    </div>
    <div>
     <h3><a href="#">Section 2</a></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>
    <div>
     <h3><a href="#">Section 3</a></h3>
     <div>
      <p>
      Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
      Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
      ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
      lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
      </p>
      <ul>
       <li>List item one</li>
       <li>List item two</li>
       <li>List item three</li>
      </ul>
     </div>
    </div>
    <div>
     <h3><a href="#">Section 4</a></h3>
     <div>
      <p>
      Cras dictum. Pellentesque habitant morbi tristique senectus et netus
      et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
      faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
      mauris vel est.
      </p>
      <p>
      Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
      Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
      inceptos himenaeos.
      </p>
     </div>
    </div>
</div>

</div>

<script type="text/javascript">            
$(document).ready(
        function() {
            $('#accordion').Accordion(
            {
                header: "h3"
            }
      );  
</script>
</body>
</html>

I've tried everything i can think of and trawled the net and still can't get this simple demo to work, can anyone point me in the right direction?

It doesn't matter what browser I use but firebug says $("#accordion").accordion is not a function

Thanks

A: 

are you sure the js reference is correct and loaded? have you tried using firebug's js debugger in order to step into the jquery code to verify this?

edit: shouldnt the function call to Accordion be lowercase?

A: 

I did one of these the other day so I know it works. Without trying your code, it's hard to catch the bug. But I think you might be OK if you change "Accordion" to "accordion."

        $('#accordion').Accordion(
        {
            header: "h3"
        }
Nosredna
Ah, I caught the upper-case A and then stopped looking. A good IDE tracks mismatches of parentheses, brackets, and braces as you go, so I never have open/close problems anymore, and I don't much look for them in other people's code as a result.
Nosredna
+5  A: 

The accordion function is all lowercase, you have also one missing parenthesis and one curly brace:

$(document).ready(
        function() {
            $('#accordion').accordion(
            {
                header: "h3"
            });
          }
      );

See your script running here and if you want to play with your code go here.

CMS
Never seen JS Bin before, very cool!
Russ Cam
Yeah, it's great for collaborative debugging!
CMS
@CMS - Remy here, author of JS Bin - something went 'funny' on the site, and this snippet was lost. I've tried to recreate it based on your solution and the code in the question (and recovered the url). Sorry - backups are being sorted!
Remy Sharp
@Remy, the snippet is up and running, thanks, and congratulations: JSBin is a really great tool!
CMS