我試圖使用select_tag選擇默認選項。下面是我收集select_tag中的選定值
@model_names = {
'Fixed' => 'fixed',
'Variable' => 'variable',
'LIBOR' => 'libor'
}
這裏是select_tag
select_tag "second_model", options_for_select(@model_names, 'LIBOR')
我都嘗試 'LIBOR' 和 'LIBOR'。甚至{'LIBOR'=>'libor'}作爲options_for_select
的第二個參數。但它不起作用。當集合是散列時,如何設置默認選項?
//編輯
哦,它適用於'libor'和...禁用JavaScript。我使用selectBoxIt插件,它不適用於它。任何人都知道如何選擇默認值使用Rails + selectBoxIt jQuery插件?
它看起來像您可以在選擇標籤的HTML屬性使用'數據selectedtext'。請參閱:http://gregfranko.com/jquery.selectBoxIt.js/#HTML5DataAttributeOptions – pdobb 2014-09-05 14:52:59