I have a form search like this:
When i used select2 for select#search_topic
, this become:
This is my select2 code:
<% content_for :head do %>
<script type="text/javascript">
$(document).ready(function() {
$('#search_topic').select2();
});
</script>
<% end %>
My form:
<%= 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 %>
I have copied select2.js
and select2.css.scss
(change name from selec2.css) to vendor/javascript
and vendor/stylesheet
.
And I changed url('select2.png')
in scss file to image_url("select2.png")
. I also copied select2.png
to app/assets/images
.
In application.js
i have //= require select2
. In application.css.scss
i have @import "select2";
.
What is wrong with my code?