I am passing an static array to jquery token input but the search results are not exact match because there is no server side query's..
like for an array ['aa','bab','aab','abb'] if I type ab I'm getting 'bab' before 'abb' and 'aab'.
can anyone help me to solve this issue..
Thank you in advance.
I'm not entirely sure how you wish to rank your results, at first I thought you wanted items that start with a string to be at the top, but then I don't see how 'aab' should come before 'bab' for the search query 'ab'.
Regardless, I think you have a few options, if you want to order the results based on the search query.
The first, which I would recommend, would be to build a server side script to handle this. It's a simple matter of pulling any exact matches to be the first item in the JSON array you'd need to return. This is the un-hacky way to go about it!
The second, if you decidedly wanted to keep it all client-side, would be to reorder your results array at the start of the populateDropdown
method in the library (c. line 843)
Finally, and the most elegant, and 'correct' way, would be to reconfigure the onResult
callback to also take the search query as a parameter, where you could then sort out the ordering of your results using the callback method.
Hope this gives some food for thought, good luck!