[Autocomplete] - how to turn off automatic selection of first item on the match list
Hi All - I recently got an autocompete search field up and running on a Shopify store, which you can see live here -
Things At Home .
I don't want the first item in the match list selected, unless a user hits down on their arrow keys. I thought I had set the correct option "highlight: false," but that doesn't seem to work - very strange. The JS I am using is:
- <script type="text/javascript">
var data = [
{% for tag in collections.all.tags %}
{text:"{{ tag | escape }}", url:"{{ shop.url }}/collections/all/{{ tag | escape }}"},
{% endfor %}
{% for product in collections.all.products %}
{text:"{{ product.title | escape }}", url:"{{ shop.url }}/products/{{ product.handle }}"},
{% endfor %}
];
jQuery(function() {
$("#search_text").autocomplete(data, {
matchContains: true,
highlight: false,
minChars: 2,
formatItem: function(item) {
return item.text;
}
}).result(function(event, item) {
location.href = item.url;
});
});
</script>
Effectively the first part creates a properly formatted multidimensional associative array for Autocompete to work on, don't worry about the Shopify code that is in there.
Can anyone offer me some advice? I sure would appreciate your help.
thanks
Miles