Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shows not all items from json #1238

Open
ourpower opened this issue May 13, 2015 · 2 comments
Open

Shows not all items from json #1238

ourpower opened this issue May 13, 2015 · 2 comments

Comments

@ourpower
Copy link

So, I have working typeahead.js script, but noticed, that sometimes(with some keywords) it shows not all results from json:

One of the case: Where is 3 objects in this received json, but search form returns only first one:

[
{
"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"
}
]

search form result:

my typeahead script:

$( 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();
        });
});

Any ideas what can be wrong?

@javiercejudo
Copy link

you might be running into #1232

@ourpower
Copy link
Author

yes, it worked, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants