Ticket #2404 (closed bug: fixed)
[autocomplete] space does not work as separator for multiple:true
| Reported by: | ayman | Owned by: | joern |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | plugin | Version: | |
| Keywords: | autocomplete, multiple, multipleSeparator | Cc: | |
| Blocking: | Blocked by: |
Description
This is ticket is for the autocomplete plugin at: http://dev.jquery.com/browser/trunk/plugins/autocomplete
When enabling the multiple option and setting the multipleSeparator option to a single space, autocomplete does not work anymore. This setup is quite common for tagging fields, in which you enter multiple tags separated by spaces.
I found the cause of the problem to be the following snippet:
function trimWords(value) {
if ( !value ) {
return [""];
}
var words = value.split( $.trim( options.multipleSeparator ) );
var result = [];
// ...
}
Calling $.trim on options.multipleSeparator removes the space and breaks the functionality of the plugin. This can be fixed by removing the call to $.trim on options.multipleSeparator.
I'm attaching a patch for this.
Thank you.
Attachments
Change History
comment:1 Changed 5 years ago by joern
- need changed from Review to Test Case
- Owner set to joern
- Summary changed from autocomplete plugin does not work with space as a separator to [autocomplete] space does not work as separator for multiple:true
- Version 1.2.3 deleted
- Milestone 1.2.4 deleted
comment:2 Changed 5 years ago by ayman
I've attached a test case as requested. Please put jquery.autocomplete.js and its dependencies in the same directory as the HTML file.
To see the bug, type in "java" in the text field and press space, and then type "p" and select "python" from the suggestions. The contents of the field will become "j a v a python" instead of "java python".
If you apply the patch, the problem will disappear.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

