Solved

jquery accordion change actions

Posted on 2013-12-20
5
534 Views
Last Modified: 2013-12-20
Hello I have this code:

<!-- Header Code -->

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
    
    <style>
    #accordion-resizer {
        padding: 10px;
        width: 350px;
        height: 500px;
    }
    </style>
    <script>
    $(function() {
        $( "#accordion" ).accordion({
            heightStyle: "fill"
        });
    });
    $(function() {
        $( "#accordion-resizer" ).resizable({
            minHeight: 140,
            minWidth: 200,
            resize: function() {
                $( "#accordion" ).accordion( "refresh" );
            }
        });
    });
    </script>


<!-- Body Code -->



<!-- HTML frag_1 -->

<!--Preamble-->
<div style="position:absolute;left:51px;top:66px;width:236px;height:170px; /*MainDivStyle*/" __AddCode="here">
    <h3 class="docs">Drag bottom right corner to resize</h3>
 
<div id="accordion-resizer" class="ui-widget-content">
    <div id="accordion">
        <h3>Section 1</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>Section 2</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>Section 3</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>Section 4</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>
<!--Postamble-->

Open in new window


   I want:
1.-to make that when you enter at first time on the page all tbas are closed because in this demo always begin with section 1 opened. I want to be closed section 1 when first time load the page and then you click on any section to open
2.-For example if you click section 2 you open section 2 but if you click again section 2 not close. I want to close the tab opened too if you click in the same tab section.
3.-Is there a way to change the colors of the title on the sections for example change "Section 1" background color and the background text and font when is opened the section change too. On the same way for other sections.
   If someone help me adding mods to the code I used  I don´t understand very well jquery and I very confused with all for now.
Thank you
0
Comment
Question by:coerrace
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39732562
To start off closed http://jsbin.com/IziKesak/1/edit?html,output
 $(function() {
        $( "#accordion" ).accordion({
            heightStyle: "fill",
           active: false,
           collapsible: true
        });
    });
    $(function() {
        $( "#accordion-resizer" ).resizable({
            minHeight: 140,
            minWidth: 200,
            resize: function() {
                $( "#accordion" ).accordion( "refresh" );
            }
        });
    });

Open in new window


If you want to change the background of the accordion header, you should be able to override the css for the ui by adding below to a style tag or external style sheet BELOW the jquery ui css.
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus {

}

Open in new window

0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39732587
I found this demo for adding styles http://demo.hongkiat.com/jquery-ui-accordion/index.html and applied the css to the demo and it works.  http://jsbin.com/IziKesak/2/edit?html,css,output

Is this what you want?
0
 

Author Comment

by:coerrace
ID: 39732635
wow padas thank you so much exactly is what I need in all points all solved.
Thank you so much you saved my life
0
 

Author Closing Comment

by:coerrace
ID: 39732641
Excellent solution
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39733289
Glad it worked out!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

867 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

16 Experts available now in Live!

Get 1:1 Help Now