Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:51:00+00:00 2026-06-07T17:51:00+00:00

I am making a Rails app, and am trying to achieve a particular functionality

  • 0

I am making a Rails app, and am trying to achieve a particular functionality relating to Twitter’s Bootstrap collapse. Bear with me as I explain it.

I currently have the following view:

enter image description here

When each of these buttons is clicked, their data-toggle div is expanded. The view is set-up as follows:

    <button class="btn dropdown" data-toggle="collapse" data-target="#keys"><i class="icon-chevron-right"></i> Keys <span class="badge badge-info pull-right"><%= @app.keys.count %></span></button>
    <button class="btn dropdown" data-toggle="collapse" data-target="#attrs"><i class="icon-chevron-right"></i> Attributes</button>
    <button class="btn dropdown" data-toggle="collapse" data-target="#edit"><i class="icon-chevron-right"></i> Edit Details</button>

    <div class="collapse indent" id="keys">
        <!--content-->
    </div>

    <div class="collapse indent" id="attrs">
        <!--content-->
    </div>

    <div class="collapse" id="edit">
        <!--content-->
    </div>

I have them set-up like this, because I want the buttons side by side, in a row. If I move the buttons to be right above the view they expand/collapse, then the buttons stack on top of one another.

So, my end goal is to have the three buttons side-by-side and have them collapse and expand their respective sections. The current set-up works, however is a little awkward. For example, if someone expands the keys section and then expands the attributes section, they have to scroll below the keys section.

There are two possible solutions to this problem. One is that pressing one button causes the other 2 to collapse themselves. This would mean that at any given time, only one of these sections is expanded.

The better solution, I think would be to have it so that when keys is expanded, the buttons to the right move down to the bottom of the keys div, and when attributes is expanded, the edit details button moves to the bottom of that div. Is this possible? I have already tried to do it by letting the buttons stack on top of each other and changing their relative locations through css, but that didn’t work because when one of the sections was expanded, the other buttons ended up in awkward spots in the middle of the expanded section.

Lastly, I would like to try to do this without the accordion style behavior as mentioned on twitter’s bootstrap page, but if someone can convince me from a design standpoint that it is preferable, I would certainly reconsider.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:51:02+00:00Added an answer on June 7, 2026 at 5:51 pm

    Using data-parent, first solution is to stick to the example selector architecture

    <div id="myGroup">
        <button class="btn dropdown" data-toggle="collapse" data-target="#keys" data-parent="#myGroup"><i class="icon-chevron-right"></i> Keys  <span class="badge badge-info pull-right">X</span></button>
        <button class="btn dropdown" data-toggle="collapse" data-target="#attrs" data-parent="#myGroup"><i class="icon-chevron-right"></i> Attributes</button>
        <button class="btn dropdown" data-toggle="collapse" data-target="#edit" data-parent="#myGroup"><i class="icon-chevron-right"></i> Edit Details</button>
    
        <div class="accordion-group">
            <div class="collapse indent" id="keys">
                keys
            </div>
    
            <div class="collapse indent" id="attrs">
                attrs
            </div>
    
            <div class="collapse" id="edit">
                edit
            </div>
        </div>
    </div>
    

    Demo (jsfiddle)

    Second solution is to bind on the events and hide the other collapsible elements yourself.

    var $myGroup = $('#myGroup');
    $myGroup.on('show.bs.collapse','.collapse', function() {
        $myGroup.find('.collapse.in').collapse('hide');
    });
    

    Demo (jsfiddle)

    PS: the strange effect in the demos is caused by the min-height set for the example, just ignore that.


    Edit: changed the JS event from show to show.bs.collapse as specified in Bootstrap documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a private Rails app that I'm trying to install locally. It's currently
I'm trying to make logging for my rails app and have some dilemmas over
I'm making Rails 3.1.1 app and trying to add some jQuery code to it.
I'm making a simple blog Rails app and am trying to output links to
I'm trying to populate the tag database for a rails app that I'm making.
I have a Rails 3 app that is trying to perform some controller action
I'm trying to have a button on the front-end of my rails app which
I'm making a Rails app where I have a method: def updateAttributes_post if logged_in?
I am currently using rails 3.0.7 and ruby 1.9.2 and making a rails App
I am currently making a rails app that will search #barcampmlk2 #{thesessionname} +1 from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.