Question

I am trying to get typeahead auto complete work and I don't see it is working.

jsfiddle

$('#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 &quot;Agent name or id &quot;" title="type &quot;Agent name or id &quot;" >
Was it helpful?

Solution

As Marwan indicated, Typeahead has been dropped from Bootstrap. Your code actually works if you include this library: http://getbootstrap.com/2.3.2/assets/js/bootstrap-typeahead.js from version 2.3.2.

Here is a working fiddle.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top