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
grouped_collection_selecttakes nine arguments. If you are passing object in with thefit only takes eight arguments.The last argument is
html_options, where you need to place theclass. This will get you theclasson theselectform field element but notoptgrouporoptionelements.Without the
:include_blank => trueit would look like this:Which should get you: