我的问题是我正在使用提前类型进行我的热门搜索工作,但只有一次ajax调用按键,但每次按键时我都会调用我的代码在下面
$.typeahead({
input: '.js-typeahead-car_v1',
maxItem: 100,
order: "asc",
hint: true,
source: {
searchkey: {
url: {
type: "POST",
url: "/search",
data: {
myKey: "muvalue"
}
}
}
},
callback: {
onClick: function (node, a, item, event) {
$("#topsearchbtn").trigger( "click" );
},
onSubmit: function (node, form, item, event) {
$("#topsearchbtn").trigger( "click" );
}
}
});
答案 0 :(得分:1)
下面的代码工作正常,我也用在我的一个项目中
$.typeahead({ input: '.js-typeahead-car_v1', minLength: 3, maxItem: 20, order: "asc", dynamic: true, emptyTemplate: "no result for {{query}}", source: { searchkey: { url: { type: "POST", url: '/search', data: { q: "myqery" } } } }, callback: { onClick: function (node, a, item, event) { $("#topsearchbtn").trigger( "click" ); }, onSubmit: function (node, form, item, event) { $("#topsearchbtn").trigger( "click" ); } }, debug: true });