View Full Version : Help Using LocalStorage
18 Aug 2011, 3:22 PM
I want to set up a cache of static data in local storage, but am stumbling over a couple of fundamentals:
How do I check to see if the current browser supports local storage?
How do I check local storage to see if my data is already there?
18 Aug 2011, 5:52 PM
To answer your first question, checking whether it is supported is not as easy as it should be due to a FF bug. See:
I'm not sure I understand your second question. What problem are you trying to solve with this check? How does this fit into an ExtJS context?
19 Aug 2011, 6:33 AM
Probably would be nice to have it in Ext.supports...
Ext.supports.LocalStorage = 'localStorage' in window && window['localStorage'] !== null;
19 Aug 2011, 10:03 AM
Agreed, though from what I've read it seems you need to wrap it in a try/catch for old FF. From a quick search of the ExtJS code it seems that this pattern is used for detecting local storage, just not assigned to Ext.supports.
21 Aug 2011, 11:28 AM
Thanks. As to my second question, I'm populating a local store with relatively static data retrieved from the server. I want to check if the local store has already been populated so I know whether to retrieve it from the server. I wound up having to read from the local store (which returns a success whether the data is there or not) and checking the record count. I thought there must be a more straightforward way to test for this.
Powered by vBulletin® Version 4.1.5 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.