I have the following code which definitely returns a proper data result if I use the 2.0.0 version, but for some reason bootstrap's typeahead plugin is giving me an error. I pasted it below the code sample:
<input id="test" type="text" />
$('#test').typeahead({
source: function(typeahead, query) {
return $.post('/Profile/searchFor', { query: query }, function(data) {
return typeahead.process(data);
});
}
});
When I run this example I'm getting a jQuery bug that says the following:
**
item is undefined
matcher(item=undefined)bootst...head.js (line 104)
<br/>(?)(item=undefined)bootst...head.js (line 91)
<br/>f(a=function(), b=function(), c=false)jquery....min.js (line 2)
<br/>lookup(event=undefined)bootst...head.js (line 90)
<br/>keyup(e=Object { originalEvent=Event keyup, type="keyup", timeStamp=145718131, more...})bootst...head.js (line 198)
<br/>f()jquery....min.js (line 2)
<br/>add(c=Object { originalEvent=Event keyup, type="keyup", timeStamp=145718131, <br/>more...})jquery....min.js (line 3)
<br/>add(a=keyup charCode=0, keyCode=70)jquery....min.js (line 3)
<br/>[Break On This Error]
<br/>return item.toLowerCase().indexOf(this.query.toLowerCase())**
Any thoughts? ... The same code works in the 2.0.0 version of the plugin, but fails to write to my knockout object model.
THIS IS WORKING TYPEAHEAD CODE FOR the 2.0.0 version:
var searchFunction = function(typeahead, query) {
$.ajax({
url: "/Profile/searchFor?tableName=" + tableName + "&query=" + query + "&extendedData=" + $("#" + extendedData).val(),
success: function(data) {
if (data.errorText != null) {
toggleLoading("false");
showDialog(data.errorText, "Error");
return;
}
var result = data.results.split("::");
typeahead.process(result);
},
select: function(event, ui) {
}
});
}
$("#" + inputBoxId).typeahead({
source: searchFunction,
onselect: function(obj) {
}
});