1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    31
    Vote Rating
    0
    mchopra1980 is on a distinguished road

      0  

    Default Unanswered: Localstorage

    Unanswered: Localstorage


    Hi,

    I am trying to store the username of my user in a localstorage. Everything works except after setting the variable "username" to the storage and then recalling the page in chrome (F5) the storage is not getting the username, i checked in the debug modus the data is there, but i retrive null from getbyid

    thanks in advance...

    Code:
    	//Create the localstore
    	var localstore = Ext.create('Ext.data.Store', {
        	model: 'app.model.LocalStore'
    	});
    
    
    	localstore.load();
    	if(localstore.getById('username')!=null){
    		console.log('Loaded:'+localstore.getById('username').get('email'))
    	}
    	console.log(localstore.add({id: 'username',email: 'mchopra2@gmail.com'}));
    	console.log(localstore.getById('username').get('email'));
    	localstore.sync();

    Code:
    Ext.define('app.model.LocalStore', {    extend: 'Ext.data.Model',
        config: {
            fields: ['id','email'],
            proxy: {
                type: 'localstorage',
                id  : 'localstore'
            }
        }
    });

  2. #2
    Sencha User jsveron23's Avatar
    Join Date
    Feb 2011
    Location
    Seoul, Korea
    Posts
    78
    Answers
    1
    Vote Rating
    1
    jsveron23 is on a distinguished road

      0  

    Default


    javascript doing asynchronous....

    you called load() method. this mean still processing.
    If you call event like, then you should use callback...

    Code:
    localstore.load(); <<--
    Code:
    localstore.load(function() {
        // code here
    }); <<--

  3. #3

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    31
    Vote Rating
    0
    mchopra1980 is on a distinguished road

      0  

    Default


    what can I do instead? I would like to store the username locally so that when the user comes back to application I have a unique identifier and keep him logged on..

  5. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    31
    Vote Rating
    0
    mchopra1980 is on a distinguished road

      0  

    Default


    I tried but still the getById returns null/undefined.

    <CODE>
    //Create the localstore
    var localstore = Ext.create('Ext.data.Store', {
    model: 'app.model.LocalStore'
    });


    localstore.load(function() {
    if(localstore.getById('username')!=null){
    console.log('Loaded:'+localstore.getById('username').get('email'))
    }
    });
    localstore.setData({id: 'username',email: 'm@gmail.com'});
    localstore.getById('username').get('email');
    localstore.sync();
    </CODE>

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi