bobomoreno
bobomoreno

Reputation: 2858

two sided multi select that works with Rails 3

I need a two sided multi select box in Rails (3.2.8), just like here:

http://www.stevefenton.co.uk/Content/Jquery-Two-Sided-Multi-Selector/

However, I can't get this to work with Rails and it is so poorly documented I have to give up on that one. (It shows but the buttons don't work, even on a fresh Rails app)

Does anyone know of a similar jquery or gem solution that DOES work with rails??

Many thanks!

Upvotes: 1

Views: 1931

Answers (1)

mccannf
mccannf

Reputation: 16659

You could try this one: http://quasipartikel.at/multiselect/

Or this is another: http://loudev.com/

And then create your select something like the following in your Rails view (the "multiple" part is important for either plugin):

<%= f.select(:country, "country_id", Country.all.collect {|c| [ c.name, c.id ] }, {:include_blank => false}, {:class => "multiselect", :multiple => "multiple"}) %>

And also have the following JavaScript in your view:

<script>
$(document).ready(function (){
     $(".multiselect").multiselect();  // If you're using the quasipartikel one
     $('.multiselect').multiSelect();  // If you're using the loudev.com one
});
</script>

Upvotes: 4

Related Questions