sliptree/bootstrap-tokenfield

typeahead problem: Cannot read property 'toString'

Opened this issue · 1 comments

this is my code

var engine = new Bloodhound({
        remote: {
            url: '/api/community/users?q=%QUERY',
            wildcard: '%QUERY'
        },
        datumTokenizer: function(d) {
            return Bloodhound.tokenizers.whitespace('name');
        },
        queryTokenizer: Bloodhound.tokenizers.whitespace
    });

    engine.initialize();
    $('#tokenfield-typeahead').tokenfield({
        typeahead: [null, {
            display: 'name',
            source: engine.ttAdapter() }]
    });

my json is the form:
[{"_id":"56a6b050d3a7b8b811324d64","name":"John","age":20,"__v":0}]

when I select an element from typeahead dropdown I get an error:
Uncaught TypeError: Cannot read property 'toString' of undefined

I guess it's the same problem of this #189