I have two input fields on my page: country and city. First one contains 100 choices and second - 2000 choices. I want to use prefetch option in typeahead plugin, because these input fields are being reused on other pages.
Then I want to filter prefetched data while typing in city input. How can I do that?
Simple answer is to use remote option of typeahead, populate url with 'country' parameter and filter data on server side. Works great but I want to use prefetch data stored on client.
Second answer is to listen to 'typeahead:selected' event and show alert message if city doesn't correspond to country. It is bad solution.
So how can I filter prefetched data?
The solution can be found in this commit. Just use
suggestionsCallback
function to filter your suggests.