dropdown

f.input 是simple_form_for的使用

这个是普通的下拉:

1
<%= f.input :tag_list,collection: @tags %>

下面这个是加了semantic-ui的下拉框(多选)

1
<%= f.input :tag_list,collection: @tags,label:"问题标签",input_html: { class: 'ui fluid search dropdown',multiple: "" } %>

html

1
2
3
4
<select class="ui fluid search dropdown" multiple="">
<option value="">State</option>
<option value="">State</option>
</select>

效果图:
屏幕快照 2016-08-30 下午1.19.20.png

下面这个是带搜索的semantic-ui下拉(多选)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<div class="ui multiple dropdown" id="dropdown">
<input type="hidden" name="filters" value="<%=@filters%>">
<i class="fa fa-users" aria-hidden="true"></i>
<span class="text" style="color:#adda4d" id="invite">邀请回答</span>
<% unless @invitated_users.nil? %>
<% @invitated_users.each do |user| %>
<a class="ui label transition visible" data-value="<%= user.id %>" style="display: inline-block !important;">
<%= gravatar_tag user.email, :size => 50, :default => avatar_url %>
<%= user.name %>
回答数量:<%= user.answers.count %>
<i class="delete icon"></i>
</a>
<% end %>
<% end %>
<div class="menu">
<div class="ui icon search input">
<i class="search icon"></i>
<input type="text" placeholder="搜索你想提问的学长学姐">
</div>
<div class="divider"></div>
<div class="header">
<i class="tags icon"></i>
学长&学姐
</div>
<div class="scrolling menu">
<% @users.each do |user| %>
<div class="item" data-value="<%= user.id %>">
<%= gravatar_tag user.email, :size => 50, :default => avatar_url %>
<%= user.name %>
回答数量:<%= user.answers.count %>
</div>
<% end %>
</div>
</div>
</div>

效果图:

屏幕快照 2016-08-30 下午1.32.30.png

这是一个二级下拉

1
2
3
4
5
6
7
<%= f.input :author,
:as => :grouped_select,
:collection => [['Authors', ['Jose', 'Carlos']], ['General', ['Bob', 'John']]],
:group_method => :last %>

效果图:
屏幕快照 2016-08-30 下午1.14.49.png