0.0
No commit activity in last 3 years
No release in over 3 years
Chosen is a javascript library of select box enhancer for jQuery and Protoype. This gem integrates Chosen with Rails asset pipeline for easy of use.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 1.0
>= 3.0
>= 0.14

Runtime

>= 3.0
 Project Readme

Chosen for rails asset pipeline

Chosen is a library for making long, unwieldy select boxes more user friendly.

The chosen_assets gem integrates the Chosen with the Rails asset pipeline.

This is a fork of chosen-rails, this gem, chosen_assets, gets already compiled .js and .css from the original chosen Github release (via the github api), and thus has no dependencies on compass (or sass or coffeescript), it just gives you the already compiled source.

Usage

Install chosen_assets gem

Include chosen_assets in Gemefile

gem 'chosen_assets'

Then run bundle install

Include chosen javascript assets

Add to your app/assets/javascripts/application.js if use with jQuery

//= require chosen.jquery

Or with Prototype

//= require chosen.prototype

Include chosen stylesheet assets

Add to your app/assets/stylesheets/application.css

*= require chosen

Enable chosen javascript by specific css class

Add to one coffee script file, like scaffold.js.coffee

$ ->
  # enable chosen js
  $('.chosen-select').chosen
    allow_single_deselect: true
    no_results_text: 'No results matched'
    width: '200px'

Notice: width option is required since Chosen 0.9.15.

And this file must be included in application.js

//= require chosen.jquery
//= require scaffold

Also add the class to your form field

<%= f.select :author,
  User.all.map { |u| [u.name, u.id] },
  { include_blank: true },
  { class: 'chosen-select' }
%>

If you use simple form as form builder

<%= f.association :author,
  collection: User.all,
  include_blank: true,
  input_html: { class: 'chosen-select' }
%>

Gem maintenance

Update chosen source in chosen_assets gem with Rake commands.

Update origin chosen source files.

rake update-chosen

That will look for the latest release from chosen's github, download the release zip, and copy assets into source. For css files, it also replaces any url() references to use rails-sass asset-url().

If chosen is out of date, feel free to do this and make a pull request!

Versioning for chosen_assets tracks chosen version -- chosen_assets 1.1.0.0 uses chosen 1.1.0, and is the first chosen_assets release of that chosen version.

Publish gem.

rake release

License

use MIT license.