Skip to content

Conversation

@astjohn
Copy link

@astjohn astjohn commented Nov 9, 2012

This behaviour is similar to the remote response.

@tkirda
Copy link
Member

tkirda commented Nov 9, 2012

You can pass additional data as data array the same way as if it would come from the server side and this would be passed to callback function.

@tkirda tkirda closed this Nov 9, 2012
@astjohn
Copy link
Author

astjohn commented Nov 9, 2012

Ok. Cool. Can you please give me an example for what the data array would look like in this situation?

@tkirda
Copy link
Member

tkirda commented Nov 9, 2012

It would be:

lookup: {
suggestions:['Liberia','Libya','Liechtenstein','Lithuania'],
data:['LR','LY','LI','LT']
}

Where data array can be array of anything, strings, numbers, objects, etc. Corresponding value will be passed to onSelect callback or custom formatting function.

@astjohn
Copy link
Author

astjohn commented Nov 9, 2012

Excellent. Thank you.

Something to consider in the future would be to eliminate the separation of suggestions from data. A cleaner API might be to couple the suggestions and data values together since they are related. For example:

[{label: 'Liberia', value: 'LR'}, {label: 'Libya', value: 'LY'}] 

Doing something like this would eliminate any array order dependencies that might exist. Unfortunately, this would break the current API and so it would be a major version change.

Either way, thanks for the library. It works really well.

@tkirda
Copy link
Member

tkirda commented Nov 9, 2012

This was done to reduce amount of data transferred through the wire. I agree with you that it would be cleaner and in the next release will implement data transformation function so that you can pass in any format that you want and transform results into format needed for the program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants