Skip to content

Commit

Permalink
Merge pull request #2509 from jhawthorn/datalist_autocomplete
Browse files Browse the repository at this point in the history
Use datalist instead of jquery-ui/autocomplete
  • Loading branch information
jhawthorn authored Jan 23, 2018
2 parents 19f82fd + 52ece09 commit 0ba913b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
1 change: 0 additions & 1 deletion backend/app/assets/javascripts/spree/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//= require jquery_ujs
//= require jquery-ui/datepicker
//= require jquery-ui/sortable
//= require jquery-ui/autocomplete
//= require jquery.sticky-kit.min
//= require solidus_admin/select2
//= require solidus_admin/underscore
Expand Down
1 change: 0 additions & 1 deletion backend/app/assets/stylesheets/spree/backend.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require jquery-ui/datepicker
*= require jquery-ui/autocomplete
*= require solidus_admin/select2
*= require solidus_admin/flatpickr/flatpickr
*= require prism
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<% end %>
</td>
<td class='property_name'>
<%= f.text_field :property_name, class: 'autocomplete' %>
<%= f.text_field :property_name, list: 'properties' %>
</td>
<td class='value'>
<%= f.text_field :value %>
Expand Down
13 changes: 3 additions & 10 deletions backend/app/views/spree/admin/product_properties/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@
<% end %>
<% end %>

<%= javascript_tag do -%>
var properties = <%= raw(@properties.to_json) %>;
$('#product_properties, #variant_property_values').on('keydown', 'input.autocomplete', function() {
already_auto_completed = $(this).is('ac_input');
if (!already_auto_completed) {
$(this).autocomplete({source: properties});
$(this).focus();
}
});
<% end -%>
<datalist id="properties">
<%= safe_join @properties.map { |name| tag(:option, value: name) } %>
</datalist>

0 comments on commit 0ba913b

Please sign in to comment.