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

Auto-completion breaks after adding custom tag #226

Closed
bendulum opened this issue Nov 6, 2013 · 2 comments
Closed

Auto-completion breaks after adding custom tag #226

bendulum opened this issue Nov 6, 2013 · 2 comments

Comments

@bendulum
Copy link

bendulum commented Nov 6, 2013

I run the plugin with the following options:

availableTags: this.persons,
allowSpaces: true,
singleField: true,
allowDuplicates: false,
singleFieldDelimiter: ',',
tagLimit: null,

whereas the "this.persons" is an array of names like [John Carpenter, Michael Bay, ...].
I want to allow the user to input names from this array via autocompletion or input custom tags in the form of email addresses.
Everything seems to work fine with the auto-completion until i enter a custom tag like "[email protected]". After that the auto-completion won't show up again for available tags!
After I remove the custom tag from the widget (by clicking the "x" or back button) the auto-completion works again.

@bendulum
Copy link
Author

I did some investigating and found the problem, at least I think so. Inside the _create method in the plugin source there is a code block for the autocompletion:

"if (!this.options.autocomplete.source) { ..."

In this block the search term (filter) is compared against the availableTags resulting in an array (choices) which is passed to the autocomplete widget.

The problem seems to be that within the $.grep loop each available tag aswell as the filter string itself have a leading whitespace! So adding the javascript native trim() to the filter variable, and each element that is compared seems to fix the problem.

Would love to see the plugin source updated with this fix, as I do not like editing the source code locally. Thanks!

@bendulum
Copy link
Author

Apparently i did not use the plugin correctly :)

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

1 participant