typeahead.js icon indicating copy to clipboard operation
typeahead.js copied to clipboard

localStorage not refreshed with prefetch

Open calexo opened this issue 13 years ago • 7 comments

Hi, localStorage doesn't seem to be refreshed when json changed, when using prefetch. Thanks !

calexo avatar Feb 21 '13 14:02 calexo

The default TTL is three days. Did you want something shorter? (use the ttl_ms option when defining a dataset to set the prefetch TTL in milliseconds) Or did it do a second request and fail to write that to localStorage?

timtrueman avatar Feb 21 '13 17:02 timtrueman

Note that the ttl_ms option isn't documented and may change in the future. We need to make it more explicit in the README that prefetched data is stored in localStorage. Also might want to make it configurable whether or not we even use localStorage. I guess you could just set ttl_ms to 0.

jharding avatar Feb 21 '13 17:02 jharding

Well, it would be good, so I tried ttl_ms like that :

  $('input[name="regionField"]').typeahead({
        name: 'regions',
        ttl_ms: 0,
        prefetch: '/getregions.json?country=FR',
        remote: '/getregions.json?country=FR&query=%QUERY'
  });

But prefetch'ed items are always the same. I don't see any error in Firebug, and there don't seem to be any new call to the prefetch URL...

calexo avatar Feb 22 '13 09:02 calexo

Hmm might be a bug. For now you can clear localStorage by running window.localStorage.clear(). I'll make sure we have a resolution for this issue in v0.8.1.

jharding avatar Feb 22 '13 09:02 jharding

Well, localStorage get cleaned. Now, I'm back to the bug I first reported on twitter : I created issue 27 Thanks

calexo avatar Feb 22 '13 09:02 calexo

I believe #34 will resolve this issue.

jharding avatar Feb 23 '13 05:02 jharding

Great !

calexo avatar Feb 23 '13 09:02 calexo