Giter Site home page Giter Site logo

select2-rails's Introduction

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.

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

To add select2-full.js instead of select2.js, add the following instead :

//= 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"

To apply the language, pass whatever language you'd like to use to the language option when initializing Select2:

$( "#dropdown" ).select2({
    language: "zh-TW"
});

Possible languages:

af, ar, az, bg, bn, bs, ca, cs, da, de, dsb, el, en, eo, es, et, eu, fa, fi, fr, gl, he, hi, hr, hsb, hu, hy, id, is, it, ja, ka, km, ko, lt, lv, mk, ms, nb, ne, nl, pa, pl, ps, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-Cyrl, sv, th, tk, tr, uk, vi, zh-CN, zh-TW

Example

Code here

Heroku app here

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})

Version

From v2.1.0 on, select2-rails's version will match the version of Select2 it uses.

The last number of the version is the patch version specific to the gem. For example, for a version of the form 2.x.y, 2.x is the release of Select2 we should be compatible with, and y is the patch version specific to the gem (ie. to resolve any gem-specific issues that crop up).

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.

select2-rails's People

Contributors

argerim avatar benlinton avatar bitsapien avatar bryant1410 avatar budnik avatar demiazz avatar doits avatar eloyesp avatar epaminond avatar eric-guo avatar frodrigo avatar grncdr avatar kbessiere avatar klausbadelt avatar lunks avatar marklazz avatar mattmenefee avatar mwanji avatar nilbus avatar opencoderx avatar p-lambert avatar pallan avatar pierpaolofrasa-twt avatar poteto avatar rolme avatar silasb avatar simi avatar slothbear avatar techfounder avatar tonyhsu23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

select2-rails's Issues

Issue with turbolinks

When using select2-rails with turbolinks, I see an error trying to use .select2() after a page is loaded with turbolinks (i.e., the first page load works fine, but the error always happens after clicking a link that causes the page to be loaded via turbolinks). The error is:

Object [object Object] has no method 'select2' 

I've found that the following piece of code being executed on page:load prevents this error:

window.Select2 = undefined;

By unsetting the Select2 global, the select2 js constructs the select2() function again, preventing the error.

I wasn't really sure where this discussion belongs, but this seemed like a good place to start. Anybody else experiencing this issue w/ select2 and turbolinks?

How do I get started with simple_form?

I would like to generate a simple multiple drop-down menu, using autocomplete. How do I do that?

This is my simple_form_for call:

<%= f.input_field :neighborhood_names, url: autocomplete_neighborhood_name_searches_path, as: :autocomplete, data: { delimiter: ',', placeholder: "Where do you want to live?"}, multiple: true, id: "selectWhereToLive", class: "span8" %>

I have successfully installed the select2-rails gem, but not quite sure how to get it working.

I add this to my home.js.coffeefile:

jQuery ->
    $('#selectWhereToLive').select2()

And am getting this error:

Uncaught query function not defined for Select2 selectWhereToLive 

Thoughts?

Edit 1:

The above simple_form_for call is producing this HTML:

<input class="autocomplete optional span8" data-autocomplete="/searches/autocomplete_neighborhood_name" data-delimiter="," data-placeholder="Where do you want to live?" id="selectWhereToLive" multiple="multiple" name="search[neighborhood_names][]" size="30" type="text" url="/searches/autocomplete_neighborhood_name" value="" />

Indicating that the id attribute is being properly set.

Version 3

Select2 is now at version 3. You should update your gem to reflect this fact.

I cannot save selected item to database.

Here is my error during saving to database : Couldn't find Textbook with id = 0.

This my params to save to database :
params[:course]
=> {"category_id"=>"11", "title"=>"web dev", "short_title"=>"wd", "duration"=>"7", "cost_per_day"=>"7", "textbook_ids"=>"[],13", "is_published"=>"1", "objectives_attributes"=>{"0"=>{"title"=>"Lesson 1", "_destroy"=>"false"}, "1368698546718"=>{"title"=>"Lesson 2", "_destroy"=>"false"}}, "summary"=>"test."}

Please help to solve it.

Thanks & Regards,
Bunhok

has no method 'select2'

After compiling assets select2 got error "Uncaught TypeError: Object [object Object] has no method 'select2' ". Some month ago it works fine. But now is broken.
My application.js.coffee:

= require jquery

= require jquery_ujs

= require select2

In development mode without compiled assets works fine. Need any advice, thanks!

Have same version number of select2

That would be veeeery nice.

Why do we need two different numbers? Looking at gem version I can understad immediatly which select2 version is installed.

This isn't Select2 2.1, is it?

It took me a while to understand why things don't work the way they did with the vanilla JS file, and then I diffed the gem's JS file and Select2 2.1's original JS file and saw a lot of changes.

It would be helpful if you'd state which version of Select2 you're using.

Version 0.0.8 placeholder text being cutoff

Relatively-sized hidden input placeholder text is cutoff until an option is selected. Setting the width of the select2 search field input after select2 is called on the element fixes this issue: $('.select2-search-field input').css('width', '100%'). This only occurs on hidden input elements, not select elements. Downgrading to 0.0.7 fixes this issue.

Track select2 versions

For version numbers I would recommend tracking select2 version numbers. Add a forth version number for your own revisions of a given select2 version. For example:

  • At v3.5.0 of select2.js =>
    • Set v3.5.0 of select2-rails for initial release
  • At v3.5.1 of select2.js =>
    • Set v3.5.1 of select2-rails for initial release
    • Set v3.5.1.1 if select2-rails had a new release while using v3.5.1 of select2.js
    • Set v3.5.1.2 if select2-rails had another new release while using v3.5.1 of select2.js

And so on...

Clearing select2 throws an error: TypeError: Cannot read property 'id' of undefined

While using select2-rails in a Spree application I've noticed that clearing the select field using:

$('.variant_autocomplete').select2('data', null)

is not working with select2-rails 3.3.1 but throws an error Uncaught TypeError: Cannot read property 'id' of undefined in select2.js

    $.fn.select2.defaults = {
        ....
        maximumInputLength: null,
        maximumSelectionSize: 0,
  -->   id: function (e) { return e.id; },
        matcher: function(term, text) {
            return (''+text).toUpperCase().indexOf((''+term).toUpperCase()) >= 0;
        },
        separator: ",",
        ....

The same call works with 3.3.0. I'm not sure where to file this issue so sorry if this is the wrong place.

Add i18n files from select2

select2 includes javascript files for different languages, it would be great if they're present in select2-rails as well.

Version 3 placeholder text being cutoff

In version 3, placeholder text is once again cutoff, items are inconsistently underlined in the select list, and the containers wrapping selected items (containing the x to remove them) collapse behind the selected item. See Issue 6.

Not opening above when off viewport

When I open a dropdown near the edge of the viewport, instead of opening above it opens hanging below the viewport edge requiring scrolling. The regular select2 examples all automatically open above in that case.

I'm using v3.4.8 with Foundation 4, and the styles for Select2 mentioned in this comment: foundation/foundation-sites#454 (comment)

I have those styles in a separate select2-foundation.css.scss file that gets included after the select2 css file from the gem.

Is this normal, a bug, or have I just done something wrong?

How to change language?

Hello,

I really have no idea. I want to override the language with my own language.

Lines:
542 and 543

formatNoMatches: function () { return "No matches found"; },
formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; },

how can I do that in my coffescript?

Thank you
Florian

undefined method `[]' for nil:NilClass in application.css.scss

I had to force gem lock on version '3.3.2' to remove the following error.

undefined method `[]' for nil:NilClass
  (in /home/funk/rails_projects/goodsounds.org/app/assets/stylesheets/application.css.scss)

After removing *= require select2 from my application.css.scss I did not have the error, but unfortunately that was not a solution. Please help. I need to upgrade!

MY application.css.scss file

/*
 *= require dataTables/jquery.dataTables.bootstrap
 *= require select2
 *= require chosen
 *= require font-awesome
 *= require ajax_pagination
 *= require_self
 *= require_tree .
*/

@import 'bootstrap';
@import 'bootstrap-responsive';
@import "font-awesome";

FULL TRACE

rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/funk/.rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
undefined method `[]' for nil:NilClass
  (in /home/funk/rails_projects/goodsounds.org/app/assets/stylesheets/application.css.scss)
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb:32:in `resolver'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb:25:in `image_url'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/funcall.rb:112:in `_perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/node.rb:40:in `perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/list.rb:70:in `block in _perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/list.rb:70:in `map'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/list.rb:70:in `_perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/node.rb:40:in `perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:298:in `visit_prop'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `map'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `map'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:7:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/root_node.rb:20:in `render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/engine.rb:315:in `_render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/engine.rb:262:in `render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-rails-3.2.6/lib/sass/rails/compressor.rb:12:in `compress'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/compressors.rb:74:in `compress'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/processing.rb:243:in `block in css_compressor='
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `evaluate'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:26:in `initialize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:19:in `block in compile'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:18:in `compile'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:56:in `internal_precompile'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/funk/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/funk/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `load'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/home/funk/.rvm/rubies/ruby-1.9.3-p374/bin...]
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:55:in `block in create_shell_runner'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `sh'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `sh'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:82:in `ruby'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `ruby'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/funk/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `load'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `<main>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/ruby_noexec_wrapper:14:in `eval'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile

No route matches [GET] "/select2.js"

Hello,

In my side_nav, I have:

<%= select_tag "Users", options_from_collection_for_select(User.all,"id", "email", @user.id) %>

with the Javascript:

$('#Users').select2();

However, an error is called and rescued:

ActionController::RoutingError (No route matches [GET] "/select2.js")

What sort of problem am I encountering?

Working with LESS

It seems gem lacks LESS support.
Please add using SASS to gem requirements in README if you do not plan to support other CSS preprocessors

Version 0.0.8 selection issue

Commit 47e2e08 appears to have broken the drop-down options list for multiple select elements. After one option has been selected, a subset of subsequent options in the drop-down list cannot be selected—while they're displayed, they're simply skipped over when trying to select them using the arrow keys or the cursor. As more options are selected, more options become unselectable from the drop-down options list. Downgrading to 0.0.7 fixes this issue.

dropdownCssClass

Recently I started using your gem to work on a RoR project and I noticed the dropdownCssClass option passed to the constructor does not pass the string class to the corresponding dropdown. Is it possible that this fix has not been updated here from the original select2?

How can i test using Rspec + Capybara

Hello,

I'm trying to test my select2 using "capybara-select2" DSL but i can't. How do you do?

I'm trying this:

select2("text that appears in the dropdown", :from => "placeholder")

The error:

undefined method `find' for nil:NilClass

Should Sass be an explicit dependency?

It seems that if an application does not requre sass-rails in its Gemfile, select2-rails fails during the asset pipeline because Sass is missing.

Would it make sense to either include sass-rails as a dependency or use the regular Select2 CSS file rather than the Sass file? What are the benefits of using the Sass version, as there don't seem to be any variables to override?

Hidden Accessible Span showing when dropdown clicked

I just recently updated my gem and I am now seeing a span that is showing the amount of options in the select tag. It looks something like this:

37 results are available, use up and down arrow keys to navigate.

I am not sure how to get rid of it and I beileve this is the code that is causing it.

this.liveRegion = $("<span>", {
                    role: "status",
                    "aria-live": "polite"
                })
                .addClass("select2-hidden-accessible")
                .appendTo(document.body);

Bootstrap styles appears not to be respected

Hello,

I have added:

 *= require select2
 *= require select2-bootstrap

to my application.css yet the BS3 do not appear to be respected.

Worse still, some selects are now only 1-2 characters wide and impossible to use, in other words they do not adopt the width of the widest option.

Any idea what configuration I might be missing?

Thanks in advance

IE8 throws errors when asset is compiled

Hi!

On IE8, when assets are precompiled for production, I'm getting "Invalid character" for select2.js and 'fn.select2.defaults' is null or not an object on select2_locale_es.js. This, however, works fine on development without the compilation. I'm running rails 4 and ruby 2, and it can be reproduced on the Heroku app example.

I think it has something to do with the UTF-8 characters on the DIACRITICS constant. Any ideas?

Thanks!

GET http://localhost:3000/assets/img/loading.png 404

The first time I click on a select2 widget, the console displays this error message. I cannot find a reference to "loading.png" anywhere in my code or my installed gems for this app except for "rich" which is not even used on this page. I'm posting this here because my app uses the select2 gem and select2.js is in the stack trace. Is select2 loading something else that attempts to load loading.png?

GET http://localhost:3000/assets/img/loading.png 404 (Not Found) jquery.js?body=1:6728
jQuery.extend.style jquery.js?body=1:6728
(anonymous function) jquery.js?body=1:6910
jQuery.access jquery.js?body=1:4123
jQuery.access jquery.js?body=1:4095
jQuery.fn.extend.css jquery.js?body=1:6893
clazz.positionDropdown select2.js?body=1:1232
postRender select2.js?body=1:1577
render select2.js?body=1:1582
clazz.updateResults select2.js?body=1:1616
clazz.opening select2.js?body=1:2706
clazz.open select2.js?body=1:1266
(anonymous function) select2.js?body=1:2624
(anonymous function) select2.js?body=1:652
jQuery.event.dispatch jquery.js?body=1:4625
elemData.handle jquery.js?body=1:4293

Dependency on sass-rails >= 3.2

In attempting to upgrade select2-rails in our app from 3.2.1 to 3.3.1 for a bugfix in select2, I've run into the following issue:

select2-rails now has a runtime dependency on sass-rails >= 3.2. sass-rails 3.2, in turn, has a dependency on railties ~> 3.2.x, which our app can't have, as we have yet to upgrade to Rails 3.2 from Rails 3.1.

Is it the intention of select2-rails to discontinue support for Rails 3.1? If not, I think this dependency on sass-rails should be loosened. If so, then close this issue and we'll bundle select2.js ourselves for the time being.

It's going to take some time to upgrade our very large app to Rails 3.2, so it'd be nice if select2-rails could support Rails 3.1 at least for a bit longer, preferably until Rails 4 is released.

Thanks.

Sass::SyntaxError

After update select2-rails (3.2.0) project error this

Invalid CSS after "...e-url(select2x2": expected ")", was ".png) !important;"
  (in /project_name/vendor/bundle/gems/select2-rails-3.2.0/vendor/assets/stylesheets/select2.css.scss)

Multiple and Ajax

Hi Guys
I want to use multiple select with ajax for has many association.
Product has many Categories.
After sending the form I am getting a string instead of array of ids :
"category_ids"=>"505341b0b543bcd4f2000021,505341b0b543bcd4f200002c,505341b0b543bcd4f2000033"

I need something like this:

"category_ids" => ["505341b0b543bcd4f2000021", "505341b0b543bcd4f200002c", "505341b0b543bcd4f2000033"]

The same problem is by rendering and loading the values from db. This is happening only by ajax multiple select since there is hidden input required.

Of course I could parse it in controller every time, but this isn't a solution.

Are there some other options?

Thx

Select2 not working in formtastic-bootstrap

I'm currently developing a ruby on rails app using twitter bootstrap. My forms are using formtastic-bootstrap. Below is my code for the forms..

app/views/shared/_form.html/erb

<div class="row">
    <%= f.semantic_fields_for :accounts, :wrapper_html => {:class => "span4"} do |acc| %>
        <%= acc.input :name, :label => "Company Name", :as => :select, :collection => Account.all ,:required => false, :input_html => { :id => 'companyaccount' } %>
        <%= acc.input :user_id, :as => :hidden, :input_html => {:value => current_user.id } %>
    <% end %>
</div> 

The codes for content_for is also in the same page on the rendered form

           <%= content_for :javascripts do %>
                 <script type="text/javascript">
                     $("#companyaccount").select2({
                     placeholder: "Select a Company"
                      });
                </script>
           <% end %>

app/assets/javasripts/application.js

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

app/assets/stylesheets/application.css.scss

*= require_self
*= require formtastic-bootstrap
*= require select2
*= require_tree .
*/

So the problem is now that select2-rails is not displaying. Any help?

please bump to 3.1 version

In your current gem I have problem with select2-choices class (grey background around selected option), but in 3.1 version from select2 repo it is all fine

Can someone update this gem to the latest select2.js?

Can someone update this gem to the latest select2.js? I'm not sure how to do it, otherwise I would! I am trying to use the select2 exports but the select2.js file in this gem doesn't include the latest. This makes it so I can't access the Select2.util.stripDiacritics() method. Thanks!

Using Select2 + rocket_tag for tagging

Have you any guidance to offer for someone that wants to use select2 for a tags field that will work with the rocket_tag rails gem? I've only just got the rocket_tag gem installed and was wondering if you had any pointers - to be able to autocomplete tags as well as create new ones.

Thanks

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can image, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post aobut this project for more information.

Heroku assets not precompiling

Im getting an error when using Select2 gem on heroku

2012-06-16T16:36:30+00:00 app[web.1]: (in /app/app/assets/stylesheets/application.css:13)):
2012-06-16T16:36:30+00:00 app[web.1]: ActionView::Template::Error (couldn't find file 'select2'

images not displaying in rails4

Images are not being displayed on rails4, I've deployed my app into an EC2 instance and run rake assets:precompile and serving files using nginx and select2 images are not found (404)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.