Skip to main content

Bug Tracker

Side navigation

#3448 closed bug (invalid)

Opened October 04, 2008 06:17PM UTC

Closed November 14, 2008 01:20PM UTC

[autocomplete] 'options.multiple' not fully disabled when false

Reported by: proasailor Owned by:
Priority: major Milestone: 1.3
Component: plugin Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:
Description

There are four references to function 'trimWords()' in the jquery.autocomplete.js code; three of them are "protected" by a check of 'options.multiple'; that is to say, 'trimWords()' is called only if 'options.multiple' is true.

This bug is caused by the 4th reference (actually the first in the source code), on line 185, which calls 'trimWords()' regardless of 'options.multiple':

$.each(trimWords($input.val()), function(i, value) {
	request(value, findValueCallback, findValueCallback);
});

The fix is VERY SIMPLE! Just add the check within the 'trimWords()' function as follows:

function trimWords(value) {
	if ( !value ) {
		return [""];
	}
	if ( !options.multiple ) {
		return [value];
	}
	...

Doing it this way allows the test to be removed from function 'lastWord()':

function lastWord(value) {
	var words = trimWords(value);
	return words[words.length - 1];
}

Without this fix, autocomplete consistently fails when the 'search()' method is used.

Attachments (0)
Change History (3)

Changed October 04, 2008 06:31PM UTC by proasailor comment:1

P.S. the problem appears when valid terms contain commas, like this:

Meningitis, Viral

Changed October 15, 2008 08:36AM UTC by proasailor comment:2

a working test case has been submitted to the plugin's author

Changed November 14, 2008 01:20PM UTC by joern comment:3

resolution: → invalid
status: newclosed

Moved to UI bugtracker: http://ui.jquery.com/bugs/ticket/3585