我正在尝试触发一个自定义事件,例如:
提前输入:选择,但没有任何反应。
我的代码列出了我想要的信息,但是当我什么也没选择时。
我在做什么错了?
var route = "autocomplete";
$('.clientName').typeahead({
minLength: 1,
highlight: true,
source: function (term, process) {
return $.get(route, { term: term }, function (data) {
return process(data);
});
}
});
$('.clientName').on('typeahead:select', function(ev, suggestion) {
alert("here");
console.log('Selection: ' + suggestion);
});
答案 0 :(得分:0)
您需要在此处typeahead:select
更改为typeahead:selected
$('.clientName').on('typeahead:selected', function(ev, suggestion) {
alert("here");
console.log('Selection: ' + suggestion);
OR
$('.clientName').bind('typeahead:selected', function(ev, suggestion) {
alert("here");
console.log('Selection: ' + suggestion);