two sided multi select that works with Rails 3

允我心安 提交于 2019-12-23 04:15:11

问题


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!


回答1:


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>


来源:https://stackoverflow.com/questions/13202929/two-sided-multi-select-that-works-with-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!