javascript - typeahead.js does not show results for array of JSON objects -
i'm using typeahead.js bloodhound remote search through our products, though valid json response empty
template keeps being shown.
products = new bloodhound( datumtokenizer: bloodhound.tokenizers.whitespace querytokenizer: bloodhound.tokenizers.whitespace remote: url: '/search.json?search[q]=%query' wildcard: '%query' ) $('#search_q').typeahead null, source: products.ttadapter() templates: empty: ' <div class="empty-message"> unable find results match current query </div> ' suggestion: handlebars.compile ' <div> <strong>{{name}}</strong> – {{url}} </div> '
the server returns json response on typing:
[ {"name":"shankh terracotta tea light holder ","type":"products","url":"/goods/6476/shankh-terracotta-tea-light-holder"}, {"name":"tess wallet ","type":"products","url":"/goods/3587/tess-wallet"}, {"name":"shankh shaped terracotta handpainted tea light holder","type":"products","url":"/goods/19483/shankh-shaped-terracotta-handpainted-tea-light-holder"}, {"name":"shankh shaped terracotta handpainted tea light holder","type":"products","url":"/goods/19487/shankh-shaped-terracotta-handpainted-tea-light-holder"}, {"name":"traditional golden tea pot","type":"products","url":"/goods/1341/traditional-golden-tea-pot"} ]
Comments
Post a Comment