2.1.0 Child Router Behavior Changes

35 views
Skip to first unread message

Josh Schanke

unread,
Jul 16, 2015, 3:08:20 PM7/16/15
to duran...@googlegroups.com
Hi, 

We recently updated one of our applications from 2.0.1 to 2.1.0 and we're seeing some very different behavior with a child router. Previously in 2.0.1 when navigating between tabs of the child router, the parent page would not be deactivated. In 2.1.0, I'm seeing deactivate get called on the parent page when you click a tab.

Was there anything that changed around this? I know the activator was changed to keep track of children and deactivate them automatically, but that doesn't seem to apply in this case.

Thanks,

Josh

Richard Hepburn

unread,
Sep 24, 2015, 12:18:32 AM9/24/15
to DurandalJS
I'm also seeing this behavior and it's quite confusing. I would not expect that when you navigate between view models defined in child routes the parent view model's deactivate() method would be called.

You can repro and see this behavior by simply adding the following code to the App/Shell.js view model in the Durandal.Samples app, running the app,  and then navigating between the "Knockout Samples" child routes and viewing the console window. You'll see that ever time a child view model is activated, the parent view model is deactivated:

    //...
   
return {

       router: childRouter,

       introSamples: ko.computed(function() {

           return ko.utils.arrayFilter(childRouter.navigationModel(), function(route) {

               return route.type == 'intro';

           });

       }),

       detailedSamples: ko.computed(function() {

           return ko.utils.arrayFilter(childRouter.navigationModel(), function(route) {

               return route.type == 'detailed';

           });

       }),

        deactivate: function () {
            console.log("ko deactivated!!!!!");

       }

    };
   
//...


What's the reasoning behind deactivating the parent view model in this scenario?


Thanks very much!

Richard

Reply all
Reply to author
Forward
0 new messages