jQuery 选择菜单与 Rails grouped_collection_select
我一直在尝试 jQuery-ui Selectmenu,但无法让它与 grouped_collection_select
一起使用。当我将类设置为“selectmenu”时,Selectmenu 与基本选择一起使用,我已设置 jQuery-ui 来查找它。基本上,我正在努力将类添加到grouped_collection_select
。
我尝试过: <%= f.grouped_collection_select(:state_id, Country.order(:id), :categories, :name, :id, :name, {:include_blank=>true, :class=>"selectmenu" })%>
和 <%= f.grouped_collection_select(:state_id, Country.order(:id), :categories, :name, :id, :name, :class=>"selectmenu")%>
我可以在我的咖啡脚本中使用 $('#user_state_id).addClass('selectmenu') 添加该类。但是,这似乎导致我的动态菜单无法更新状态选择菜单的选项。
对我在这里缺少什么有什么想法吗?有没有更好的方法来设置 grouped_collection_select 的类。我检查了源代码,没有使用 :class=> 添加类在grouped_collection_select
中。
选择菜单: http://jquery-ui.googlecode.com/svn/branches /labs/selectmenu/index.html
I have been playing around with the jQuery-ui Selectmenu, but haven't been able to get it to work with the grouped_collection_select
. The Selectmenu works with the basic select when I set the class to "selectmenu," which I have set the jQuery-ui to look for. Basically, I'm struggling to add Class to grouped_collection_select
.
I have tried:<%= f.grouped_collection_select(:state_id, Country.order(:id), :categories, :name, :id, :name, {:include_blank=>true, :class=>"selectmenu"})%>
and<%= f.grouped_collection_select(:state_id, Country.order(:id), :categories, :name, :id, :name, :class=>"selectmenu")%>
I was able to add the class using $('#user_state_id).addClass('selectmenu') in my coffeescript. However, this seemed to cause my dynamic menu from being able to update the options for my State select menu.
Any thoughts on what I'm missing here? Is there a better way to set the class for grouped_collection_select. I've checked the source code and the class is not being added using :class=> in grouped_collection_select
.
The selectmenu:
http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/index.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
grouped_collection_select
有九个参数。如果您使用f
传递对象,则只需要八个参数。最后一个参数是
html_options
,您需要在其中放置class
。这将为您提供select
表单字段元素上的class
,而不是optgroup
或option
元素。没有
:include_blank =>; true
它看起来像这样:这应该让你:
grouped_collection_select
takes nine arguments. If you are passing object in with thef
it only takes eight arguments.The last argument is
html_options
, where you need to place theclass
. This will get you theclass
on theselect
form field element but notoptgroup
oroption
elements.Without the
:include_blank => true
it would look like this:Which should get you: