开发者

how can I set a default value on a jquery ui multiselect

开发者 https://www.devze.com 2023-02-28 05:29 出处:网络
I am creating a collection_select in rails like this <%= collection_select(:company, :business_type_id, @business_type, :id, :name, {:prompt => true},:id=>\"companyType\") %>

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) %>
0

精彩评论

暂无评论...
验证码 换一张
取 消