I am creating a collection_select in rails like this
<%= collection_select(:company, :business_type_id, @business_type, :id, :name, {:prompt => true},:id=>"companyType") %>
then with Jquery, I am turning it in t开发者_运维技巧he multiselect widget:
$("#companyType").multiselect({
multiple: false,
noneSelectedText: "Type",
selectedList: 1
});
I would like to set a default value to it... any ideas on how?
You can set the default option using the Rails view helper. This is what i gather from the documentation of the widget
<%= collection_select(:company, :business_type_id, @business_type, :id, :name, {:prompt => true},:id=>"companyType", :selected => @business_type.id) %>
精彩评论