Question

I have a classic master detail view on my durandal App, in the first view I have a list of entities and a filter box, this filter box makes the list refresh with the applied filters.

Clicking an entry makes the browser navigate to the detail view. All good here. The problem is when I go back all my filter selections are gone and the list reloads without filters. I have seen durandal samples and this is not suppose to happen, the activate method is called, but the VM is not instantiated.

Can someone throw me some pointers here. All the router setup, activation, etc is the default.

I am using durandal 2.0

Was it helpful?

Solution

OK, I got it, i was actually returning a function from the vm module for the main view, this will make the vm to instantiate everytime, I now return a new object and the problem is solved:

Before:

 define([
    'plugins/router',
    'knockout'
],
    function (router,ko) {
        var listview= function() {
            //allMyobservables here, etc
        }
        return listview
    }
);

Now:

 define([
    'plugins/router',
    'knockout'
],
    function (router,ko) {
        var listview= function() {
            //allMyobservables here, etc
        }
        return new listview()
    }
);

Works as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top