I have an input field in bootstrap 3 and I want to make it autocomplete with values from some local data, so I chose bootstrap-typeahead. The problem is that when the user chooses some value, I want to change the source of typeahead so that this value is no longer included in the available options. I have simplified a jsfiddle because the only thing that I can't do is change the source.
The following code doesn't work.
autocomplete.on('typeahead:closed', function( i, j) {
//change source
autocomplete.data('typeahead').source = altdata.ttAdapter();
});
Here: http://jsfiddle.net/gtzoumis/rdC3Z/4/
There are some answers for previous versions but none of them work.
the answer was to destroy the object and create it again... thanks to this link
autocomplete.typeahead('destroy');
$('.autocomplete').typeahead(null, {
name: "autocomplete",
displayKey: 'name',
source: altrepos.ttAdapter()
});