2011-04-24 78 views
0

我在軌創建collection_select這樣我怎麼可以設置多選

<%= collection_select(:company, :business_type_id, @business_type, :id, :name, {:prompt => true},:id=>"companyType") %> 

然後使用jQuery一個jQuery UI的默認值,我把它在多選部件:

$("#companyType").multiselect({ 
    multiple: false, 
    noneSelectedText: "Type", 
    selectedList: 1 
}); 

我想設置一個默認值...任何想法如何?

回答

0

您可以使用Rails視圖助手設置默認選項。這是我從widget

<%= collection_select(:company, :business_type_id, @business_type, :id, :name, {:prompt => true},:id=>"companyType", :selected => @business_type.id) %>