简体   繁体   中英

Turn off typeahead autocomplete temporarily

I am using bloodhound to suggest products from a list. Once selected, input fields will automatically be filled in for the user.

When a user has selected a product, the autocomplete suggestions must be disabled temporarily - but the input must still be changeable . If a user presses a button to deselect the product, all input fields will be cleared and the suggestion engine must be enabled again.

I am trying to create two functions: enableSuggestions() and disableSuggestions() . Is there any way to achieve this?

If you disable the input that typeahead works on, the suggestions will be disabled as well.

You can disable the input when a suggestion is selected ( typeahead will trigger an event - typeahead:select ) and remove the disabled attribute when the user deselects the product.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM