Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#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:
Blocked by: Blocking:

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 (2)

autocomplete.patch (514 bytes) - added by ayman 12 years ago.
autocomplete-testcase.html (930 bytes) - added by ayman 12 years ago.
Test case

Download all attachments as: .zip

Change History (7)

Changed 12 years ago by ayman

Attachment: autocomplete.patch added

comment:1 Changed 12 years ago by joern

Milestone: 1.2.4
need: ReviewTest Case
Owner: set to joern
Summary: autocomplete plugin does not work with space as a separator[autocomplete] space does not work as separator for multiple:true
Version: 1.2.3

Changed 12 years ago by ayman

Attachment: autocomplete-testcase.html added

Test case

comment:2 Changed 12 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.

comment:3 Changed 12 years ago by ayman

[ping]

Any updates? Is there anything else I need to do?

Thanks.

comment:4 Changed 12 years ago by DanSwitzer2

I've added this patch to the source code.

comment:5 Changed 12 years ago by scott.gonzal

Resolution: fixed
Status: newclosed

Fixed in [4862]. Thanks Dan!

Note: See TracTickets for help on using tickets.