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

Documentation suggestion #19

Closed
corford opened this issue Nov 16, 2018 · 2 comments
Closed

Documentation suggestion #19

corford opened this issue Nov 16, 2018 · 2 comments

Comments

@corford
Copy link

corford commented Nov 16, 2018

Hi.

Because of this line in the keyup function:

if (keypressCounter === savedKeypressCounter && elements) {

If elements is an empty array (which evaluates to true in javascript), the update() function is called. If elements is false (i.e. developer chooses to ignore the current documentation and passes false as parameter to the fetch callback), update() is not called.

This is actually quite nice as it gives the developer a choice of what to do in the situation where e.g. they are using ajax to power the autocomplete suggestions and a user types the beginning of a place name, ajax returns with some results and user keeps on typing. In this case, if another ajax request is fired but this time no results come back, the developer can decide whether to pass an empty array in the fetch calback (thus closing the suggestions) or pass false (which would keep the suggestions open from the first ajax result).

I am using the above technique at the moment and it is actually quite useful. Maybe the documentation for fetch should mention this possibility so others can benefit?

@corford
Copy link
Author

corford commented Nov 16, 2018

Also, another doc suggestion! :)

var countries = [
    { label: 'United Kingdom', value: 'UK', group: "North America" },
    { label: 'United States', value: 'US', group: "North America" },
    { label: 'Uzbekistan', value: 'UZ', group: "Asia" },
];

UK is not in North America. Maybe Canada makes more sense...

var countries = [
    { label: 'Canada', value: 'CA', group: "North America" },
    { label: 'United States', value: 'US', group: "North America" },
    { label: 'Uzbekistan', value: 'UZ', group: "Asia" },
];

@kraaden
Copy link
Owner

kraaden commented Nov 17, 2018

Thank you for the suggestions, Charlie. I updated the docs.

@kraaden kraaden closed this as completed Nov 17, 2018
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

2 participants