1. #1
    Ext JS Premium Member
    Join Date
    May 2011
    Location
    Northern California
    Posts
    227
    Vote Rating
    15
    Answers
    2
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      0  

    Default Unanswered: Help Using LocalStorage

    Unanswered: Help Using LocalStorage


    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?
    Thanks

  2. #2
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,078
    Vote Rating
    112
    Answers
    453
    skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold

      0  

    Default


    To answer your first question, checking whether it is supported is not as easy as it should be due to a FF bug. See:

    http://diveintohtml5.org/detect.html

    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?

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,624
    Vote Rating
    434
    Answers
    3104
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Probably would be nice to have it in Ext.supports...

    Code:
    Ext.supports.LocalStorage = 'localStorage' in window && window['localStorage'] !== null;
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  4. #4
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,078
    Vote Rating
    112
    Answers
    453
    skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold

      0  

    Default


    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.

  5. #5
    Ext JS Premium Member
    Join Date
    May 2011
    Location
    Northern California
    Posts
    227
    Vote Rating
    15
    Answers
    2
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      0  

    Default


    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.

Tags for this Thread