Bootstrap-3-Typeahead
Bootstrap-3-Typeahead copied to clipboard
Typeahead error: Uncaught TypeError: Cannot read property 'name' of undefined
Admittedly I am just messing this up somewhere, but when I use:
<script type="application/javascript" >
$(document).ready(function(){
var tags = JSON.parse('["test","testtest","test","asdfasdfasdf","Test","not","a","tag","at","all","awesome","never","Sizes","New Options","New Option Set","test","NameIsBoobos","thenameliterallyisgone","notTagsEleent","NotWorking"]');
console.log(tags);
$('#tags').tagsinput({
typeahead: {
source: tags
}
});
});
On:
<input id="tags" type="text" name="Product[tags]" value="<?php echo implode(",", json_decode($tags)); ?>" class="form-control">
I get the error:
Uncaught TypeError: Cannot read property 'name' of undefinedTypeahead.displayText @ bootstrap3-typeahead.js:248Typeahead.select @ bootstrap3-typeahead.js:83Typeahead.click @ bootstrap3-typeahead.js:397Z.extend.proxy.Z.isFunction.i @ jquery.js:1Z.event.dispatch @ jquery.js:2Z.event.add.m.handle @ jquery.js:2
While it shows the typeahead dropdown perfectly, it doesn't add it to my input value on click, but does add it to the tagsinput field (So I can see it, but the value isn't updating).
PS: The json parse I use cause I echo the data from an PHP array, I saw it on a stackoverflow post...
how it can be correct can you find any answer اجاره خودروhttps://ejarehkhodro.com کرایه ماشین در تهرانhttps://021rent.com
@PistolPete13 Did you ever figure out the solution here? I'm having the same issue.
I figured out that the data I was using for source
had a value null
in it – and Typeahead definitely doesn't like that! My array looked like:
["Carrie","Michael",null]