Volt::Chosen
This gem provides Volt bindings for Chosen, a library for making long, unwieldy select boxes more user friendly.
Status
This is a 0.1; I put it together in a rush for my own purposes. I'm using it for multiple selects, but haven't tested any other functions.
Installation
Add this line to your application's Gemfile:
gem 'volt-chosen'
Then add component 'chosen'
in your component's config/dependencies.rb
.
Usage
Do something like this in your view:
<:chosen multiple="true" chosen_options="{{ {placeholder_text_multiple: 'Any'} }}" value="{{ model.research_status_keys }}" options="{{ Practice::RESEARCH_STATUSES }}" />
Options
Any of the Chosen options can be passed through the chosen_options attribute as shown above.
Events
important
The change
event that Chosen fires on select was throwing an error in Volt 0.9.6 when it caught somewhere higher up the stack. I didn't have time to fully chase it down, so instead this gem currently catches change
and raises chosen:change
. Thus, you must use chosen:change
if you want to do something with the change event.
Credit
Thanks to all the folks who contribute to Chosen, it's amazing!
Contributing
- Fork it ( http://github.com/matthew342/volt-chosen/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
List of needs:
- Some integration tests for multiple selects
- Test and tweak to make sure single selects work
- Would be nice to add support for
optgroup
s