-1

我刚刚开始使用 Ember.js,我只是不知道如何在多个插座中加载动态数据。基本上,我想这样做:http ://cl.ly/image/0H0e1a2j1x0I 。

在第一部分:单击菜单并更新正确的内容。在第二部分:点击菜单“圈子”并更新下面的内容。

我不知道正确的解决方案,我开始做嵌套路由,但它似乎不是正确的方法。

如果有人有提示那就太好了!

谢谢

4

1 回答 1

0

There are at least three approaches you could take.

1.Since you mention multiple outlet, then you can use nested routes. You can specify rendering multiple outlets at once by using the render method within the renderTemplate function of each route. Check out a thread with fiddle that shows this approach Ember template chaining Separate outlets means separately bound models and controllers, but easily render state based on url. For example if you select Press releases / Articles and info is shown on the right, the url will be something like yourapp/#/all-info/press and that can be bookmarked and easily rerendered.

For example in your case it could be applied as having an outlet for showing the page and menu (yourapp/#/all-info), nested outlets for showing the right part (yourapp/#/all-info/company, yourapp/#/all-info/press, yourapp/#/all-info/media etc ), a nested outlet for the circular menu (yourapp/#/all-info/features), nested outlets for each detail of circular i.e. (yourapp/#/all-info/features/journalists, ..../features/in-place, ..../features/responsive etc). Then you play around with the routes and render methods in order to combine as you wish.

2.Multiple views for each segment within a template of the page. http://emberjs.com/guides/views/inserting-views-in-templates/ . This means that you will share the model of the specified route among your views. This can either work for the whole page (single outlet) or at least for some groups of segments and combine it with few outlets from first approach.

For example in your case one outlet for whole page or one outlet for top part (side menu and details), one outlet for bottom part(ciruclar menu and details). Then each view could have separate views for menu and view for details you would end up with 2 container views top and bottom and 4 views master-detail for menus and details.

3.Use only one template that will render your model to the different segments. Maybe the worst approach but fine for a fast prototype before breaking it down to one of the previously mentioned solutions.

于 2013-10-09T07:42:41.213 回答