1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Answers
    1
    Vote Rating
    4
    Tegola is on a distinguished road

      0  

    Default Unanswered: Save current route url to localStorage

    Unanswered: Save current route url to localStorage


    Hello,
    since the only way to restore the state of a web app added to the iOS homescreen is by using routing, I'm searching for a way to store the current route's hash url to localStorage, so I can load it the next time the user opens the app.

    The easiest way to store the url is:
    Code:
    localStorage.setItem('url', location.hash.substr(1));
    However, I need to save this url everytime the app launches a "redirectTo(...)". I didn't find a specific event or a way to intercept it. How do you do it?

    Thanks

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Code:
    Ext.define('controller',{
        config:{
            before:{
                showUser:'storeUrl'
            },
            routes:{
                'user/:id': 'showUser'
            }
        },
        storeUrl:function(action){
            localStorage.setItem('url', location.hash.substr(1));
            action.resume();
        }
    })
    I write English by translator.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Answers
    1
    Vote Rating
    4
    Tegola is on a distinguished road

      0  

    Default


    Thanks for your reply.

    That means that I need to add a "before" config for every action. There's a clean way to launch it before ANY action?

    Here's my dirty method:

    Code:
    if (Ext.feature.has.History) {
    	window.addEventListener('hashchange', Ext.bind(saveUrl, this));
    }
    
    function saveUrl(location){
    	var hash;
    		
    
    	if (location.hash) { // object
    		hash = location.hash;
    	} else if (location.newURL)  { // hashchange event
    		var anchor = document.createElement('a');
    		anchor.href = location.newURL;
    		hash = anchor.hash;
    		delete anchor;
    	}
    	localStorage.setItem('url', hash.substr(1));
    }

Thread Participants: 1

Tags for this Thread

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