Skip to content

Conversation

@pachisaez
Copy link

The Autocompleter is designed to send constantly Ajax requests while you are filling in a field to get the results that fit the input. And so it should work in most cases.

But there is a case where this is not desirable: when you are filling a text area where not every token requires auto-completion. As an example you have the “What’s happening?” box on Twitter. You can enter any text, but if you type a “@” the Autocompleter is activated to look for your friends.

In my application I have a similar box, and I need Autocompleter to run only when a user types a “#” (for tags) or a “:” (for special keywords). If Autocompleter were always running and a lot of users were writing at a time, the server performance would be seriously impaired.

So I have added support for a regexp option. If it exists, Ajax requests are done only if the token matches with the regexp pattern. E.g. regexp: /(#|:)(\w)*/ would activate Ajax requests for tokens that start with ‘#’ or ‘:’.

What do you think?

…ax requests are done only if the token matches with the "regexp" pattern. Useful when using text areas where not every token requires auto-completion. E.g. regexp: /(#|:)(\w)*/ would activate Ajax requests for tokens that starts with '#' or ':'.
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

Successfully merging this pull request may close these issues.

1 participant