PDA

View Full Version : localStorage not working in store



blessan
10 Aug 2010, 4:24 AM
I followed this thread to create the dataview.

http://www.sencha.com/forum/showthread.php?105155-DataView-is-not-working-with-ArrayStore/page2&highlight=dataview+touch

Everything worked.

Here my code



var apptStore = new Ext.data.ArrayStore({
proxy : new Ext.data.MemoryProxy(),
fields : ['clientName', 'apptTime', 'service', 'apptText']
});
apptStore.loadData([{"clientName": "Evylyn", "apptTime": "10:00 AM", "service": "Womens Hair Cut"},{"clientName":"John Doe", "apptTime": "11:00 AM", "service": "Womens Hair Cut"}]);

new Ext.DataView({
store : apptStore,
scroll:false,
tpl : new Ext.XTemplate(
'<tpl for=".">',
'<div class="apptListItem">',
'<div class="ticketList">',
'<p class="ticketListName">{clientName}<span>4:30 PM</span></p>',
'<p>Women\'s Hair Cut</p>',
'<p class="apptLongText">Power is perishable, and when politicians exit the stage, it often doesn\'t take long -- especially in Washington -- for their importance to be only vaguely recollected.</p>',
'</div>',
'</div>',
'</tpl>'),
overClass : 'x-view-over',
itemSelector : 'div.thumb-wrap',
emptyText : 'No images to display'
})


But when I try to keep the store array in local storage and use


apptStore.loadData(localStorage.getItem('apptList5'));

I get this error

Uncaught TypeError: Object [ has no method 'join'

I have no idea what is goin wrong. When I print the 2 arrays they are both showing the same string. Can some one help

evant
10 Aug 2010, 5:52 AM
console.log(typeof localStorage.getItem('apptList5'));


Is it a string?

blessan
10 Aug 2010, 7:38 PM
I applied eval and now it works