Typeahead 未显示 json 中的所有项目

Typeahead shows not all items from json

所以,我有工作的 Twitter typeahead.js 脚本,但注意到,有时(使用一些关键字)它不会显示 json:

的所有结果

案例之一: 此接收到的 3 个对象在哪里 json,但搜索表单 returns 只有第一个:

[
{
"query":"David Flanagan - JavaScript",
"id":"7",
"image":"\u003Cimg src=\u0022http:\/\/bks5.books.google.lt\/books\/content?id=4RChxt67lvwC\u0026printsec=frontcover\u0026img=1\u0026zoom=1\u0026edge=curl\u0026source=gbs_api\u0022\u003E"
},
{
"query":"Stoyan Stefanov - JavaScript Patterns",
"id":"10",
"image":"\u003Cimg src=\u0022http:\/\/bks8.books.google.lt\/books\/content?id=ZEmbAgAAQBAJ\u0026printsec=frontcover\u0026img=1\u0026zoom=1\u0026source=gbs_api\u0022\u003E"
},
{
"query":"Douglas Crockford - JavaScript: The Good Parts",
"id":"9",
"image":"\u003Cimg src=\u0022http:\/\/ecx.images-amazon.com\/images\/I\/518QVtPWA7L._SL160_.jpg\u0022\u003E"
}
]

搜索表单结果:

我的预输入脚本:

$( document ).ready(function() {
    var books = new Bloodhound({
        datumTokenizer: Bloodhound.tokenizers.obj.whitespace,
        queryTokenizer: Bloodhound.tokenizers.whitespace,
        remote: {
            url: '/search/auto/?q=%QUERY',
            wildcard: '%QUERY',
        }
    });

    $('#books_search').typeahead({
            hint: true,
            highlight: true,
            minLength: 3,
            limit: 5
        },
        {
            name: 'book-search',
            display: 'query',
            source: books,
            templates: {
                empty: [
                    '<div class="empty-message">Unable to find any books that match the current query</div>'
                ]
            }
        }).on('typeahead:selected', function(e, data) {
            $("#search-form").submit();
        });
});

有什么想法是错误的吗?

所以这是 typeahead.js 错误,这里是解决方案:(已提交,但尚未在 master 中):

https://github.com/twitter/typeahead.js/pull/1200

你试过用这个吗 datumTokenizer:Bloodhound.tokenizers.obj.whitespace("query"); (我使用本地数据而不是远程数据,但两者的工作方式相同) 这是演示-link,效果很好 http://jsfiddle.net/7q3xk10y/