Solved

jquery accordion change actions

Posted on 2013-12-20
5
520 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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 tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

760 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

20 Experts available now in Live!

Get 1:1 Help Now