0.0
No commit activity in last 3 years
No release in over 3 years
Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results. This gem integrates Select2 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
 Dependencies

Development

~> 1.0
>= 3.0

Runtime

~> 0.14
 Project Readme

#Select2 for Rails asset pipeline

Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.

This repo is a continuation of the dead select2-rails project.

The select2_rails gem integrates the Select2 jQuery plugin with the Rails asset pipeline.

Gem Version

Usage

Install select2_rails gem

Add select2_rails to your Gemfile and run bundle install:

gem "select2_rails"

Include select2_rails javascript assets

Add the following to your app/assets/javascripts/application.js:

//= require select2

alternatively, for the full build:

//= require select2.full

Include select2_rails stylesheet assets

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

*= require select2

If you are using Twitter Boostrap you need to also require the bootstrap theme CSS in addition to the above require.

*= require select2-bootstrap

To apply the theme, tell Select2 to do so by passing bootstrap to the theme option when initializing Select2:

$( "#dropdown" ).select2({
    theme: "bootstrap"
});

Internationalization (i18n)

The select2_rails now supports multiple languages.

Add the following to your app/assets/javascripts/application.js:

//= require select2_locale_"any possible language"

Possible languages:

az, bg, ca, cs, da, de, en, es, et, eu, fi, fr, gl, hi, hr, hu, id, is, it, lt, lv, mk, nb, nl, pl, pt-BR, pt, ro, ru, sk, sr, sv, th, tr, uk, vi, zh-CN, zh-TW

Fix

IE8 Invalid Character

IE8 doesn't support some unescaped Unicode character and need to quote keys in object literals You need some configurations for Uglifier to do the work. Add to your config/environments/production.rb

   require 'uglifier'
   config.assets.js_compressor = Uglifier.new(output: {ascii_only: true, quote_keys: true})

Contributions

If you want to contribute, please:

  • Fork the project.
  • Make your feature addition or bug fix.
  • Send me a pull request on Github.

License

selec2_rails is released under the MIT License.