Wrap autocomplete suggestion in href

Hi all.

I’m having a bit of a problem with the autocomplete drop down I’m looking for a little help on if anyone has an idea. I have my results coming back correctly when typing into the input but what I am trying to achieve is to wrap this span in a link to a specific product.

I have an entry in my index called item_code and I want to append it to the end of a static link. In my autocomplete javascript I have the following code

templates: {
    //'suggestion' templating function used to render a single suggestion
    suggestion: function(suggestion) {
      return '<a href="https://mysite.com/products/' + 
        suggestion.item_code.value + 
        '">' +
        '<span>' +
        suggestion._highlightResult.item_code.value + '</span><span>' +
        suggestion._highlightResult.description.value + '</span></a>';
    }
}

This creates the correct link structure but the item_code is displayed as undefined which results in a 404 error.
So how do I correctly reference the item_code to get it to work in this way?
Thanks for any help available :slight_smile:

All sorted! The problem was me adding .value to the suggestion line.
Working a treat now :slight_smile: