سؤال

I am trying to use the accordion feature of Twitter Bootstrap in my Rails app. However, collapses result in overlapping divs, non-hiding sections, etc. I've tried to install the transitions plug-in, or specifically include it in the manifest, but I can't seem to get it right or find instructions that are up to date for Rails 4, Bootstrap 3 and the bootstra-sass gem.

How can I get the accordion feature to work given my environment?

application.js

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .

Gemfile

#Assets
gem 'jquery-rails'
gem 'jquery-turbolinks'
gem 'purecss-rails'
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
gem "paperclip", "3.5.4"
gem 'normalize-rails'
gem 'bootstrap-sass'
...

The simple accordion example from the bootstrap site I'm trying to get up and running

<button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#demo">
    simple collapsible
</button>

<div id="demo" class="collapse in">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth ne</div>

Thanks in advance.

هل كانت مفيدة؟

المحلول

I am guessing by the lack of mention that you have not added the references to the Bootstrap stylesheet in your stylesheets/application file.

  1. Convert app/assets/stylesheets/application.css to application.css.scss (if it isn't that way already).

  2. Add the line @import 'bootstrap';

After that, you should be good. Bootstrap makes the accordion work by adding and removing styles that have CSS transitions on them, so if you don't have the styles, then most of the Bootstrap stuff will not work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top