mancmanomyst
mancmanomyst

Reputation: 2118

JQuery accordion not hiding sections

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

Upvotes: 0

Views: 2224

Answers (3)

Christian C. Salvad&#243;
Christian C. Salvad&#243;

Reputation: 827496

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.

Upvotes: 5

Nosredna
Nosredna

Reputation: 86216

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"
        }

Upvotes: 0

code-o-mat
code-o-mat

Reputation:

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?

Upvotes: 0

Related Questions