-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API to refresh prefetched data on-demand? #223
Comments
Ahm... I am expeting for the same thing..... |
Your best bet may be to define datasets without a function onSave() {
// ...
$('.typeahead')
.typeahead('destroy')
.typeahead({ prefetch: '/data.json' });
} |
@jharding Yeah, I did see that mentioned in other issues regarding this topic, however I was hoping to retain the localStorage feature of the typeahead, because this is a round-trip application, so disabling the localStorage would mean that on every page load the data would have to be re-prefetched from the server. And since there will definitely be considerable lengths of time when the user is just navigating between pages whilst making no changes to the dataset, making a request for the data on every page load is just an unnecessary burden on the server. I noticed in the |
The only time data is fetched from the remote endpoint is on initialization so clearing localStorage wouldn't help. Honestly, right now there isn't a really great way of implementing what your asking about. The best way to go about this is to probably build something into typeahead.js for refreshing datasets. |
I read through the docs and did some searching but wasn't really able to find a definitive answer on this; is their a way to programmatically clear prefetched data stored in localStorage from some arbitrary point in my application's logic?
For instance, I have a wiki-type application that allows the users to create/modify articles, and the data source of the typeahead is that same collection of articles. When the user creates an article and it gets saved to the server, it would be expected that the article would instantly show up in the typeahead results, so I would want a way to essentially refresh the cached dataset at that specific point. It would also be nice to be able to do this periodically while the user has the app open, by checking the server to see if its locally cached data is outdated and refresh it before the default expire time (which is a few days or so) is reached.
If this is not do-able via the typeahead's API, is there another workaround such as removing the specific dataset from localStorage manually, so that when the typeahead instance looks for it and it is not there, it at that point re-fetches it?
The text was updated successfully, but these errors were encountered: