简体   繁体   中英

Durandal canDeactive lifecycle callback

I currently have my canDeactive callback being called twice when I return false.

The call stacks are identical with the only difference being that in system.js the acquire function args variable has differing values on each call.

The first time my breakpoint in the nested setTimeout is hit the args have a value of my navigating to view.

The second time round (split second) the args value is of my current view that I have stated may not deactivate.

Does this sound familiar to anyone? Am I perhaps doing something wrong with my require statements in each view

Edit More Info

My setup: (- denotes nesting)

Shell

-header

-view1

--nested view (bound using knockout)

-view2

-view3

--nested view

In order to navigate between views I have a property on each view that states it's page heading and also any link items, so for example view1 header: "Page 1", links [{path: "#/view2"}]. Each one of my views 'requires' the header view, and sets these options on activate (I dislike this piece as it feels like a hack but that's for another day).

When clicking a link I call a function on the shell which in turn calls router.navigateTo( path of item clicked ) or back on view3.

I can confirm this issue occurs across all views (1,2 and 3), and also canActivate along with the other lifecycle callbacks fire once as expected and in the correct order.

Sorry for the lack of code but I'm not sure where to look as it seems to be something that controls the requireing on navigation (due to the single difference found mentioned above)

我已经解决了我的问题,问题的孩子是我的default.html,将我的脚本导入移动到了我的applicationhost下(la durandal演示),我的canDeactivate在收到错误返回时不再触发两次。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM