Domanda

I have a pair viewmodel/view in my application that it is used for displaying different data. The data that is displayed is generated by some user input and a separate route for each set of data is registered on the router.

The problem is that because the same view/viewmodel is used for different routes, when navigating between them, the binding between view-viewmodel is not refreshed.

Hooking up to canReuseForRoute callback I managed to get the viewModel refresh, but the view is not refreshed.

I tried to use cacheVews on the router binding but the views were still not refreshed.

How can I make the router/routing composition refresh when navigating to a different route that is using the same view/viewmodel?

EDIT : (more info) Hooking on the binding callback I discovered that Durandal binds the view only the first time the module is used. If I try to navigate to a different route with the same module (view/viewmodel) it does not call the binding callback again.

È stato utile?

Soluzione

Try overriding areSameItem on the activator as explained in this answer. Returning false should get Durandal to go through the whole page lifecycle again, whereas I think using canReuseForRoute doesn't necessarily.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top