ruby - How can a dropdown be stylized when using twitter bootstrap with simple_form in a Rails app? -
i using simple_form , twitter-bootstrap-rails gems. every thing working fine somehow drop-down not getting stylized twitter bootstrap rails ..it shows normal forms.
<%= f.input :category, :collection => ["one", "two", "three", "four"], :input_html => {:class => 'dropdown'}, :label => 'send to', prompt: "choose list" %> image of dropdown showing:
image of dropdown needed in bootstrap

one way stylized dropdowns simpleform , bootstrap use bootstrap-select. there rails gem it; add gemfile , bundle:
gem 'bootstrap-select-rails' you need add stylesheet
@import "bootstrap-select"; and javascript.
//= require bootstrap-select now, need use input_html: {class: 'selectpicker'} in existing f.input:
<%= f.input :category, :collection => ["one", "two", "three", "four"], :input_html => {:class => 'selectpicker'}, :label => 'send to', prompt: "choose list" %> and initialize javascript (which one-off regardless of how many selectpickers have):
<%= javascript_tag "$('.selectpicker').selectpicker();" %> restart app , input dropdown should render bootstrap styling.
some info may useful: can disable prompt item cannot selected dropdown adding disabled class item. couldn't find guidance on simpleform how apply style 1 element of collection came below such prompts:
<%= javascript_tag "$('li[data-original-index=0]').addclass('disabled');" %>
Comments
Post a Comment