I have an autocomplete function in my application. Auto-filling works fine, typing gives me the correct results. However, I want these results to be clickable links in addition to just filling out the search box.
Product controller:
def index @products = Product.where("title like ?", "%#{params[:title]}%") respond_to do |format| format .js format.html
Coffee script:
jQuery -> $('#search').autocomplete source: $('#search').data('autocomplete-source')
View:
<%= text_field_tag :search, params[:search], data: {autocomplete_source: products_path(id: 'product.id') } %>
So, I think somewhere I need to pass the identifier to JSON and then get jQuery to show that identifier when I refer, but I don't know how to do it. Thanks.
source share