Opened 15 years ago
Closed 13 years ago
#3228 closed bug (invalid)
[autocomplete] MustMatch does not work if entry has white spaces at the end
Reported by: | jose.raya | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | plugin | Version: | 1.2.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If mustMatch is activated we have found that, when the entry contains a white space at the end, once we select the value from the list it is rejected. We have found the problem and it is in the search event: At line 184 you trim the value of the input: $.each(trimWords($input.val()), function(i, value) {
request(value, findValueCallback, findValueCallback);
}); but when you compare with the value in the list (line 175) you don't trim the list value: if( data[i].result.toLowerCase() == q.toLowerCase() ) {
result = data[i]; break;
}
As a result of this, the value in the input field is not found in the list and is rejected.
The solution that works for us is to trim the list value before comparing: if( trimWords(data[i].result).toLowerCase() == q.toLowerCase() ) {
result = data[i]; break;
}
This is not a jQuery core bug. Please report plugin bugs to the plugin's author, or ask on the jQuery forums. jQuery UI bugs should be reported on the UI bug tracker, http://dev.jqueryui.com .