Closed nebaughman closed 2 years ago
There is a sample in a readme that shows this. Because final format is always suggestion
object.
You can always open a PR with an updated documentation.
Thank you for your quick reply. I think the issue, then, is that lookup
must return results in the "final format" suggestion
object, which does not support string[]
of suggestions.
Response Format in the documentation mentions that:
Alternatively, if there is no data you can supply just a string array for suggestions
... which is misleading, because it's not true for the return type of lookup
. Is this intentional? I wouldn't want to add special-cases to the documentation if this is just an unintentional bug. Thanks for clarifying.
No it is not intentional, this issue never came up. Just how it was done initially.
Ok, thanks for clarifying. Looking at the code, the done
callback given to lookup
is the getSuggestions()
function. Seems that, by this time, the results must be in the final format you mentioned (cannot accept a string[]
at this point). I'm not very familiar with the inner workings (yet?), but maybe the workflow could be altered to handle string[]
at that point. Also, instead of a done
callback, this could be handled with a Promise. I'll look into it when I have some time. Thanks for helping me understand the intent.
jquery-autocomplete v1.4.11
The documentation implies that lookup suggestions can be provided as a
string[]
or an array of{ value: string, data: any }
objects. When using aserviceUrl
,transformResult
can produce a response like:However, when using a
lookup
function, the response (given to thedone
function) cannot be formatted like that. It must be formatted as:The
data
properties are optional, but you cannot just use astring[]
for the suggestions.For instance:
Please clarify the documentation or (better) allow the lookup function to produce the simpler
{ suggestions: string[] }
format. Thanks!