我正在努力让typeahead自动完成工作,但我认为它不起作用。
$('#selectAgent').typeahead({
source: function(query, process) {
objects = [];
map = {};
var data = [{"id":1,"label":"machin"},{"id":2,"label":"truc"}] // Or get your JSON dynamically and load it into this variable
$.each(data, function(i, object) {
map[object.label] = object;
objects.push(object.label);
});
process(objects);
},
updater: function(item) {
$('id').val(map[item].id);
return item;
}
});
// HTML:
<input name="selectAgent" type="text" id="selectAgent" class="validate[required] text-input form-control" data-prompt-position="topLeft:70" placeholder="type "Agent name or id "" title="type "Agent name or id "" >
答案 0 :(得分:1)
正如Marwan所说,Typeahead已从Bootstrap中删除。如果您包含此库,则代码实际上有效:版本2.3.2中的http://getbootstrap.com/2.3.2/assets/js/bootstrap-typeahead.js
。