Results 1 to 2 of 2

Thread: Directly loading invalid LocalStorage record throws an exception

Hybrid View

Previous Post Previous Post   Next Post Next Post
    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    28
      0  

    Default Directly loading invalid LocalStorage record throws an exception

    Directly loading an invalid LocalStorage record throws an exception instead of calling provided failure callback.

    I am attempting to check if a record is in local storage on startup using something like the following test case. Instead of calling the failure callback an error is being thrown.

    WebStorage.js:201
    Uncaught TypeError: Cannot read property 'id' of null


    Code:
            Ext.define('User', {
                extend: 'Ext.data.Model',
                fields: ['id', 'name'],
                proxy: {
                    type: 'localstorage',
                    id: 'user'
                }
            });
            
            Ext.onReady(function() {
                var User = Ext.ModelManager.getModel('User');
    
                User.load(1, {
                    success: function(user) {
                        console.dir(user);
                    },
                    failure: function() {
                        console.log('Failure');
                    }
                });
            });

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Heres how you can detect localStorage support:

    // Feature test
    var hasStorage = (function() {
    try {
    localStorage.setItem(mod, mod);
    localStorage.removeItem(mod);
    return true;
    } catch(e) {
    return false;
    }
    }());
    anuncios clasificados
    *LIFE'S SHORT. If you don't look around once in a while you might miss it*
    anuncios clasificados
    *LIFE'S SHORT. If you don't look around once in a while you might miss it*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •