How to dynamically display tabs for routes in Durandal?

风流意气都作罢 提交于 2019-12-20 04:31:13

问题


This is a two part question. Am very new to durandal and knockout.

Using the HTML Starter Kit example for Durandal 2.0.1.

I add a route for customers/:id with my own vm and view with nav = false

 { route: 'customer/:id', moduleId: 'viewmodels/customer/customer', nav: false }

Because nav is false, it doesn't get used when buildNavigationModel() is called. So the shell.html doesn't show a tab entry for it. So far so good.

  1. When I navigate to c:\temp\index.html#customer/123 I can see the page, but it doesn't get included in the tabs at the top of the page. When I look at shell.html it uses data-bind to get the routes to display in those tabs. So shouldn't it display this new route I just moved to? If I set the routes, nav to true, would that be enough to refresh the shell display? Or am I failing at my first attempt to understand ko?

  2. So I have a route for customer/:id. If I go to index#customer/123 I want to see a new tab as of part 1 above. If I navigate to index#customer/234, I want to see a new tab for that as well. The user should then be able to move between the two tabs. Can this work, or is it really only recording the customer/:id route and I will only ever see one tab button?


回答1:


The router navigation model won't do what you're looking for. Check out Durandal 2.0 routing parameterized routes (same route different parameter) to see an example how to build your own navigation model instead.



来源:https://stackoverflow.com/questions/21677597/how-to-dynamically-display-tabs-for-routes-in-durandal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!