我正在使用带有json响应的远程URL(New typeahead.js)
我的JavaScript:
$(document).ready(function() {
$('input.country').typeahead({
valueKey: 'name',
remote : {
url : 'example.in/d.php?query=%QUERY',
filter: function (parsedResponse) {
var dataset = [];
for (i = 0; i < parsedResponse.length; i++) {
dataset.push({
name: parsedResponse[i].name
});
}
if (parsedResponse.length == 0) {
dataset.push({
name: "No results"
}); }
return dataset;
},
},
});;
})
我的json响应:
[{“ name”:“ Nokia 110”,url:“ example.com/nokia-110”},{“ name”:“ Nokia 210”,url:“ example.com/nokia-210”}]] >
所以如何在所选名称上提供URL链接?
我正在使用带有json响应的远程URL(New typeahead.js)我的javascript:$(document).ready(function(){$('input.country')。typeahead({valueKey:'name',remote: {url:'example.in/d.php?query =%...
您需要更新Typeahead.js使用的模板,并在其中显示URL。
感谢托比提供总体思路
我是这样的: