2013-01-18 191 views
0

我有Twitter的引導下拉列表的頁面Twitter的引導下拉+引導,多選

.btn-group 
    %a.btn.dropdown-toggle{"data-toggle"=>"dropdown", href: "#"} 
     Test 
     %span.caret 
    %ul.dropdown-menu#dropdown-menu-test1 
     - if data.any? 
     - data.each do |account| 
      %li 
      %label.checkbox 
       %input{ type: :checkbox, value: some_value, name: "test", checked: some_condition}some data 

我工作好上,但我想將其轉換爲https://github.com/davidstutz/bootstrap-multiselect。要做到這一點,我必須用%select - %option替換%ul - %li,這是我所做的。

%select{class: "multiselect", multiple:"multiple", id: "multiselect-test", name: "multiselect-test-name"} 
    %option 
     test1 
    %option 
     test2 

但事實證明,沒有能力檢查頁面加載的一些選項。還有更多,params["multiselect-test-name"]是零。

那麼,我該如何處理這兩個問題:缺少一些選項檢查頁面加載(取決於some_condition)和缺少params["multiselect-test-name"]的能力?

回答

0

你應該嘗試這樣options_for_select(["test1", "test2", "test3"])

例如選擇:

%select{class: "multiselect", multiple:true, id: "multiselect-test", name: "multiselect-test-name", options_for_select(["test1", "test2", "test3"])} 

它會爲你工作inshaAllah ..