1 viewmodel multiple routes: lifecycle

后端 未结 1 1677
死守一世寂寞
死守一世寂寞 2021-01-20 06:00

I\'d like to have a couple of different routes pointing to the same view/viewmodel and I have managed to make this happen.

            { route: \'formulation         


        
1条回答
  •  無奈伤痛
    2021-01-20 06:38

    I think your best bet is to override areSameItem on the activator (which is created by the router as activeItem). Somewhere early on in the wireup of your application, try doing this:

    var routerAreSameItem = router.activeItem.settings.areSameItem;
    
    router.activeItem.settings.areSameItem = function (currentItem, newItem, currentActivationData, newActivationData) {
        debugger;
        return routerAreSameItem.apply(this, _.toArray(arguments));
    };
    

    Obviously this particular implementation isn't going to do anything; but you should be able to provide some custom logic in the areSameItem method to distingish the item change.

    If my memory serves correctly, returning false from that method should make your activate method get called.

    0 讨论(0)
提交回复
热议问题