-
Notifications
You must be signed in to change notification settings - Fork 121
Closed
Description
Hi @running-coder,
What an amazing plugin! I cannot believe I have never heard about it until today.
Thank you very much for making this available to the community.
Anyway, I am having trouble setting the 'path' value given my ajax response below:
[
{
"_id": "5878e8c35683511de6ae0601",
"updated_at": "2017-01-16T15:58:51.655Z",
"created_at": "2017-01-13T14:48:35.380Z",
"_category": "586eaef338cf980c1815c7d1",
"title": "Carousel",
// ...
},
{
"_id": "5878eaf02379251e125142ed",
"updated_at": "2017-01-16T15:59:57.317Z",
"created_at": "2017-01-13T14:57:52.321Z",
"_category": "586eaef338cf980c1815c7d1",
"title": "Gauges",
// ...
},
// ...
]
I tried:
$.typeahead({
input: ".js-typeahead",
order: "asc",
source: {
articles: {
ajax: {
url: "/articles/search",
path: "" // ******** I have tried ' ', [0], [0].title
}
}
},
emptyTemplate: "no result for {{query}}",
highlight: true,
backdrop: {
"background-color": "#000"
},
callback: {
onInit: function (node) {
console.log('Typeahead Initiated on ' + node.selector);
},
onClick: function (node, a, item, event) {
// You can do a simple window.location of the item.href
alert(JSON.stringify(item));
},
}
});
Can anyone spot the issue? Thank you in advance!