PDA

View Full Version : Problems with IE7



yogev
12 Nov 2012, 3:45 AM
Hi. I'm currently using ExtJS 4.0.7 and I'm trying to create a store with the following code:

new Ext.data.Store({
proxy: {
type: 'localstorage'
}
});

It generates an error on IE7:


Line: 55535
Char: 9
Error: 'undefined' is null or not an object
Code: 0

I went down to this line in my file ext-all-debug.js and I saw:

initialize: function() {
var storageObject = this.getStorageObject();
storageObject.setItem(this.id, storageObject.getItem(this.id) || "");
}
Which is part of Ext.data.proxy.WebStorage.

How can I solve this error?

Thanks ahead.

tvanzoelen
12 Nov 2012, 6:49 AM
LocalStorage is a HTML5 thing probably not supported in IE7 and it thows some kind of strange error.

To test this you could try this if it raises the error Local Storage is not supported in this browser, please use another type of data proxy




var test = new Ext.data.proxy.WebStorage({ id : 'myid'});

yogev
12 Nov 2012, 7:01 AM
Hi. Thanks for the quick reply. Another question in the subject...
Can I use 'memory' proxy type instead? What's the difference?

Thanks

tvanzoelen
12 Nov 2012, 7:11 AM
I think localstorage saves key value pairs persistent in the client browser. After a reload of a page you can reload the data form the localstore. Its a kind of cookie thing.

Memory proxy can handle more complex datatypes but the data only remains for one browser session/page load.

I think local storage is not supported in all browsers yet and there seems to be some performance/security issues with it. For Mozilla example https://blog.mozilla.org/tglek/2012/02/22/psa-dom-local-storage-considered-harmful/

If there is no need to save data, use a memoryproxy. If you have persistent data you can better save it on your server so you are sure it remains available.