Thursday, December 18, 2008

AutoComplete Bug: item has comma won't select (but I have workaround)

Found an AutoComplete bug:

I've just found a bug with AutoComplete plugin. If one of the items in the list retrieved has an embedded comma in the string, the string is not considered 'matched'. This is with options 'multiple' false.

This I discovered because I've implemented the 'afterNoMatch()' method (see an other post to this list). If I select an item from the list that has an embedded comma, it will trigger the afterNoMatch() and consider the item not matched.

This could impact otherse even if they don't have this patch because this means the mustMatch option will not trigger as they think it will.

I haven't found the true cause, but it would seem to have something to do with multiple selections - like it's on by default anyway. So the workaround is to specify another multipleSeparator character. Here, I use backtick:

$("#mcOrgName").setOptions({multipleSeparator: '`' });

where mcOrgName is the jquery name of the field I'm using autocomplete for.

Here's hoping the author does a bugfix, but in the mean time, this workaround should enable full functionality presuming you don't need backticks in the text you're selecting.

Post a Comment