I am using the Bootstrap-3 Typeahead plugin as well as the Bootstrap Tag Input plugin. I use it like this:
<input type="text" id="name" name="test" data-provide="typeahead">
And the jQuery:
$.get('/design/assets/advertisements/countries.json', function(data) {
$("#name").typeahead({
source: data
});
$('#name').tagsinput({
typeahead: {
source: data
}
});
}, 'json');
However, the typeahead and tags works to some point. Whenever I enter some words, i get suggestions, but whenever I've selected a suggestion, whatever I was writing will be added after the tag input.
Example: If I write "Bah
" and select "Bahamas
", it looks like this: (Where I would believe that it would delete the "Bah")
I get this error - I don't know if that's the reason:
Uncaught TypeError: Cannot read property 'name' of undefined
The error is called to this file: bootstrap3-typeahead.js
I've downloaded non-min version of bootstrap-3 typeahead plugin and changed this:
displayText: function(item) {
return item.name || item;
},
to this
displayText: function(item) {
if (typeof item == 'undefined') {
return '';
}
return item.name || item;
},
It solved the problem.
Actually I don't know whether it's a bootstrap-3 typeahead plugin bug or some kind of it's incompatibility with bootstrap tags input plugin which I use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With