none
Store Arrays or bindings when opening new html page RRS feed

  • Question

  • Hi,

    I have built an App for Excel that has 2 pages one page has user instructions. While the user is using the app, I created an option of opening the user instruction to get some help. What i have picked up is that when it come back to main user-interface, it has erased all data and bindings are empty. How can i save the binding so that when the user comes back to the main user-interface the data and binding still exists.

    The default App for Excel template has a code, but i don't understand it. 

    Please help.

    Regards


    Bongani Zulu

    Monday, March 17, 2014 7:53 PM

All replies

  • Hi,

    >>What i have picked up is that when it come back to main user-interface, it has erased all data and bindings are empty.<<

    According to your description, I suspect the issue is caused by page refresh in the main user-interface page. Since I don't know how you jumped between the two pages in the code, would you mind sharing some sample code for us reproducing?

    In general, I suggest you using JavaScript for page navigation. You could pass the bindings parameters when jumping between 2 pages. Or open a new browser window to display another page using JS.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 18, 2014 8:48 AM
    Moderator
  • hi luna,

    i use javascript code like this

    function back() {
        window.location.href = '../Home/Home.html';
    }


    Bongani Zulu

    Thursday, March 20, 2014 7:39 PM
  • Are you sure it will default to bind the data in the Home.html?

    Tuesday, March 25, 2014 9:19 AM
  • But every time the new page loads, the app runs the app.initialize functions which is contained in the Office.Initialize, which declares the app.binding global variable. I tried to customize the Office.Initialize function to reading "myBinging" as I open open the App, but I could not.

    Bongani Zulu

    Tuesday, March 25, 2014 10:59 AM
  • Hi Bongani Zulu,

    The data binding is stored in the memory before persisting to document (by saving the document). “window.location.href” will force page reloading which will start a new page session (all bindings not persisted to document will be lost).

    For a workaround, I suggest to you to operate the HTML DOM elements for navigation (CSS3 + HTML5 + Javascript). For more information, you could also refer to Single-Page Applications: Build Modern, Responsive Web Apps with ASP.NET.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, March 26, 2014 9:07 AM
    Moderator
  • >>window.location.href = '../Home/Home.html'<<

    Above code will refresh the whole page, then you will lost your bindings. 

    you can use jQuery '$.get', '$.post' to refresh your page. e.g.

    $.get('../Home/Home2.html',function(res){
    
       // Hidden page1 $('div#page1').hide();
    
      //  Show page2 with res content
    
    });
    
    you can search 'jquery get()' from www.bing.com to get more detail.
    Friday, March 28, 2014 10:14 AM
  •       Is the scenario that binding is newly created in the main page and then navigate to another page? If so, in Excel client, like Jeffery-chen said, the binidng will be lost, and you need to use some workaround to switch between the two page. But in Excel online, the binding is auto saved to server, so although switching the page, the binding can also saved.  And Because the binding have ID when you create, you can use this API Office.context.document.bindings.getByIdAsync(bindingId, function (asyncResult)  to get it again. 

           Besides, if the binding isn't newly created in the main page, you can always use this  API Office.context.document.bindings.getByIdAsync(bindingId, function (asyncResult)  to get it again.

    Monday, March 31, 2014 8:38 AM