0
votes

I created navigation app with 2 page control.

I have a list view on the first page, which gets values from external js and ajax request. I navigate to page2.html from home and from page2.html to home.

The first time the app loads. It loads everything. But if I click the browsers back button or navigate to first page. IT doesn't call the function:

(function(){
    "use strict;
    WinJS.UI.pages.define("/pages/home/home.html,{
    ready: function (elemnet, options) {

        document.getElementById('txtserver').value ="test";
        basicListView.addEventListner("iteminvoked",handler);
    }
)};

I'm calling this page from page2 like this: WinJS.navigation.navigate('/pages/home/home.html');

I want the page to load like the first time I open the app. However, it seems like navigation back in app doesn't refresh page or data inside like list view.

home->page1 (ready works) page1->home (ready doesn't work)

How do I refresh a page with content on navigation?

1
So do you have home, page1, and page2, or just home and page2? Also, can you confirm that the ready method in home.js above is called the first time you run the app? And is home.html what's pointed to in the PageControlNavigator in default.html? I ask because when a page control's methods aren't called it's typically a mismatch between the names of files and what's in WinJS.UI.Pages.define. Because generally speaking, if you nav to a new page, it gets loaded and everything in ready gets executed. Also, I'm confused if you're just asking about ready or about data loading more generally. - Kraig Brockschmidt - MSFT
the history back does not refresh the page, you have to make sure that all the initialization that you nedd happens in your ready method, that will happen every time - Maurizio In denmark

1 Answers

0
votes

If you add your event listener using element.querySelector as shown below, it should work always.

element.querySelector(‘#txtserver’).textContent = "test";
element.querySelector(‘#basicListView’).addEventListner("iteminvoked",handler);