Results 1 to 2 of 2

Thread: How to run window.location from localstorage with out page continuous reload?

  1. #1
    Sencha User
    Join Date
    Nov 2013
    Posts
    49
    Answers
    1

    Default How to run window.location from localstorage with out page continuous reload?

    Hi,
    I have a view where i have 3 buttons,
    On clicking on each items i am redirecting to different URL to load a new theme based on platform. means my homepage launch with different theme.

    below the code for Choosetheme.js
    Code:
     listeners: {				
    itemtap: function(cmp, index, target, record, e, eOpts){
    
    var anil = window.location.href;
    var blackthme = '';
    
      if(index == 0)
      {
       window.location.assign(location.pathname+'?platform=thmblack');
       blackthme = anil+'?platform=thmblack';
    
      localStorage.setItem("thmepath" , blackthme);
      }  
      if(index == 1)
      {
       window.location.assign(location.pathname+'');
       blackthme = anil+'';
    
      localStorage.setItem("thmepath" , blackthme);
      }  
      if(index == 2)
      {
       window.location.assign(location.pathname+'?platform=thmyellow');
       blackthme = anil+'?platform=thmyellow';
    
      localStorage.setItem("thmepath" , blackthme);
      }
    }
    here i am able to set the themepath url in localstorage.

    In my main.js i am getting the path from localstorage, because untill the user changes his theme after reload also same theme theme should be there.

    i places below code in main.js intialize function.
    Code:
    if(window.location == localStorage.getItem('thmepath')){
    window.location.href = localStorage.getItem('thmepath');
    }
    due to above code in console i am able to see localstorage get path properly, but my page keep on loading due to keeping it in intialize function.

    Suggest me better way to do it.


    Advance Thanks.

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,108
    Answers
    342

    Default

    Have you checked the network panel to see what was going on with the request? Have you tried forcing a window.location.reload()?
    Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services [email protected]

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

Posting Permissions

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