javascript - jQuery Typeahead - Uncaught TypeError: Cannot read property 'name' of undefined -


i using bootstrap-3 typeahead plugin bootstrap tag input plugin. use this:

<input type="text" id="name" name="test" data-provide="typeahead"> 

and jquery:

$.get('/design/assets/advertisements/countries.json', function(data) {     $("#name").typeahead({         source: data     });     $('#name').tagsinput({         typeahead: {             source: data         }     }); }, 'json'); 

however, typeahead , tags works point. whenever enter words, suggestions, whenever i've selected suggestion, whatever writing added after tag input.

example: if write "bah" , select "bahamas", looks this: (where believe delete "bah")

enter image description here

i error - don't know if that's reason:

uncaught typeerror: cannot read property 'name' of undefined 

the error called file: bootstrap3-typeahead.js

i've downloaded non-min version of bootstrap-3 typeahead plugin , 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 problem.

actually don't know whether it's bootstrap-3 typeahead plugin bug or kind of it's incompatibility bootstrap tags input plugin use.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -