Submit Your Article Forum Rules

Results 1 to 4 of 4

Thread: Jquery UI

  1. #1
    Senior Member ristenk1's Avatar
    Join Date
    Apr 2009
    Posts
    108

    Jquery UI

    I haven't been here in awhile but hoping that someone can help me out with something that should be simple. I'm trying to use Jquery UI for the first time. I am using Google's hosted API library and just copied the "accordian" code from the Jquery site but can't get it to work. I don't know if the problem is with my linkage to the google library (I've been playing around with this a bit) or with the code itself. here it is 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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>

    <script src="https://ajax.googleapis.com/ajax/lib....7.0/jquery.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/lib...6/jquery-ui.js" type="text/javascript"></script>


    </head>
    <body>
    <SCRIPT>
    $(function() {
    $( "#accordion" ).accordion();
    });
    </SCRIPT>

    <DIV class=demo>
    <DIV id=accordion>
    <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>
    <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>
    <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>
    <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><!-- End demo -->
    <DIV style="DISPLAY: none" class=demo-description>
    <P>Click headers to expand/collapse content that is broken into logical sections, much like tabs. Optionally, toggle sections open/closed on mouseover. </P>
    <P>The underlying HTML markup is a series of headers (H3 tags) and content divs so the content is usable without JavaScript. </P></DIV><!-- End demo-description -->
    </body>
    </html>



    Can someone take a look and see if it's my link to google or something in the code that I have to change? Thank you

  2. #2
    Administrator rah's Avatar
    Join Date
    Jul 2003
    Posts
    2,511
    I assume you are talking about this: http://jqueryui.com/demos/accordion/

    If so, it looks like your event is starting before the page is ready.

    Have you tried:


    jQuery(document).ready(function(){ $('#accordion').click(function() { $(this).next().toggle(); return false; }).next().hide();});


    <edit>It also looks like you are missing the js files for the jqueryUI itself</edit>

  3. #3
    Senior Member ristenk1's Avatar
    Join Date
    Apr 2009
    Posts
    108
    Thanks Rah, I think you were right.. I moved the script into the head section. I also added the Google hosted style sheet but I think it was the first correction that did it:

    <link href="http://ajax.googleapis.com/ajax/libs.../jquery-ui.css" rel="stylesheet" type="text/css"/>
    <script src="http://ajax.googleapis.com/ajax/libs...n.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs...n.js"></script>

    Thanks for your help!

  4. #4
    Administrator rah's Avatar
    Join Date
    Jul 2003
    Posts
    2,511
    I'm glad you got it working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •