$(document).ready(function() {
$('#client-select2').select2();
});
If i place the code above to application.js, it does not respond but if I place it in the _form.html.erb file, it does. Anyone know why that is?
views/orders/_form.html.erb
<script type="text/javascript">
$(document).ready(function() {
$('#client-select2').select2();
});
</script>
<%= simple_form_for(@order) do |f| %>
<%= f.error_notification %>
<%= f.input :code %>
<%= f.association :client, collection: Client.all, label_method: :name, value_method: :id, prompt: "Choose a Client", required: true, input_html: { id: 'client-select2' } %>
<%= f.submit %>
<% end %>
application.html.erb has
<%= javascript_include_tag 'application' %>
jQueryfunction.