1

所以我在 Rails 中的 Record 和 Counties 之间有一个多对多的关系,这样当我创建记录时,用户可以选择多个县。问题是有100多个县可供选择。

因此,我正在寻找一种更用户友好的方式来允许选择多个县,而不是 formtastic 的默认设置。

我找到了这个博客,但它引用的插件有点旧,似乎不再可用...... http://diminishing.org/extending-formtastic-with-a-sprinkle-of-jquery

有人用 Rails 3/Formtastic 实现了任何东西来解决这个问题吗?

提前致谢。

4

1 回答 1

0

I have just used Select2 in a project with Rails 3 and Formtastic and it works quite well.

Select2 supports multi-value select boxes, so if the select is declared with the multiple attribute then Select2 will automatially pick up on that. Thus, all you need is to do the following:

$("#multiple_select").select2();

More documentation here: http://ivaynberg.github.io/select2/

于 2013-04-14T16:29:23.180 回答