我有一个这样的表单搜索:
当我使用select2时select#search_topic
,这变成:
这是我的 select2 代码:
<% content_for :head do %>
<script type="text/javascript">
$(document).ready(function() {
$('#search_topic').select2();
});
</script>
<% end %>
我的表格:
<%= form_tag({ controller: 'questions', action: 'search_filter' }, method: 'get', class: 'form-inline') do %>
<%= label_tag 'search_topic', 'Filter:', class: 'label_search' %>
<%= select_tag 'search_topic', options_from_collection_for_select(current_user.get_topics, :id, :name), :prompt => "Select topic" %>
<%= select_tag 'search_type', options_from_collection_for_select(@question_types, :id, :name), :prompt => "Select type question" %>
<%= submit_tag "Search", name: nil, class: 'btn' %>
<% end %>
我已将select2.js
and select2.css.scss
(从 select2.css 更改名称)复制到vendor/javascript
and vendor/stylesheet
。
我将url('select2.png')
scss 文件更改为image_url("select2.png")
. 我也复制select2.png
到app/assets/images
.
在application.js
我有//= require select2
。在application.css.scss
我有@import "select2";
。我的代码有什么问题?