issa-tseng / awesomecomplete

A lightweight autocomplete plugin for jQuery. Autocomplete that doesn't suck — I think.
http://dontexplain.com/2009/08/jquery-plugin-lautocomplete/
52 stars 7 forks source link

wrong check in defaultRenderFunction #3

Closed mackuba closed 14 years ago

mackuba commented 14 years ago

The 'if' in defaultRenderFunction checks whether topMatch is equal to 'name', but:

1) name field doesn't have to be called 'name'; 2) name field should never appear in topMatch anyway (see line: if ((field != config.nameField) ...)

I guess this should be "if (topMatch === null)" instead.

issa-tseng commented 14 years ago

You're correct about point 1. I'll look again when I have more time about point 2.

Fixed and pushed, thanks.

mackuba commented 14 years ago

Try running a query on a collection of objects with a single field "name". I have such case and I'm getting a whole list of results with "null: undefined" below them, because topMatch is null (it's initialized to null and it isn't changed if it's the name field).

issa-tseng commented 14 years ago

If you're convinced of this, I'll make the change without running through the code myself.