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

No results found in case if suggestions.length equals to limit #30

Closed
abguy opened this issue Nov 1, 2015 · 3 comments
Closed

No results found in case if suggestions.length equals to limit #30

abguy opened this issue Nov 1, 2015 · 3 comments

Comments

@abguy
Copy link

abguy commented Nov 1, 2015

Hello,

We use typeahead.js version '0.11.1'.

Our code looks like:

this.bloodhound = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    identify:       this.identify.bind(this),
    local:          this.localData,
    remote: {
        url:        this.searchUrl,
        wildcard:   this.searchWildcard
    }
});

$(this.input).typeahead({
    highlight:  true,
    hint:       true,
    minLength:  1
}, {
    display:    this.toString.bind(this),
    source:     this.bloodhound,
    limit:      5,
    templates: {
        pending:    this.loadingTemplate,
        empty:      this.emptyTemplate
    }
});

As you can see we have no prefetch/cache enabled, but we have some local data before initialization.

Problem

If I type something and exactly 5 items are returned I see "No items found" message (this.emptyTemplate). But there were 5 items found!

Additional info

I think that this issue is caused by Dataset.update() function logic:

rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));

Thus it appends zero items.

BTW, typeahead is awesome! Thanks!

@mlissner
Copy link
Contributor

mlissner commented Dec 3, 2015

I think I'm seeing this too. it's enough to make you feel absolutely crazy. Did you find a workaround? Frankly, I don't want any limit logic at all, since my remote endpoint just returns 20 or fewer results no matter what.

@jvdbrink20
Copy link

I use the limit: Infinity workaround suggested in the other github repo. I limit my results server side.
Couldn't find the 'limit' property usage in code so I can't suggest a fix and do a PR.

@jlbooker
Copy link
Contributor

Looks like this was fixed in #52, with further discussion in #43. Closing.

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

No branches or pull requests

4 participants