I'm having a little trouble with Twitter Typeahead. It throws me the following error:
Uncaught TypeError: Cannot read property 'length' of null jquery.js:4
I've looked at some other cases, but none of them match mine.
My Code:
var companies = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '_companies?query=%QUERY',
wildcard: '%QUERY'
}
});
var users = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('username'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '_users?query=%QUERY',
wildcard: '%QUERY'
}
});
companies.initialize();
users.initialize();
$('#username').typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'companies',
displayKey: 'name',
source: companies.ttAdapter(),
templates: {
header: '<h4 class="hint-title">Bedrijven</h4>'
}
}, {
name: 'users',
displayKey: 'username',
source: users.ttAdapter(),
templates: {
header: '<h4 class="hint-title">Gebruikers</h4>'
}
});
Maybe there is someone else who has/had a similar issue?