EmberJs: how to use connectOutlet

[亡魂溺海] 提交于 2019-12-11 15:05:21

问题


I've created a simple test in which I try to use connectOutlet. However, not much is rendered. Here is my test code: http://jsfiddle.net/jeanluca/53dpA/

Just to summarize the application. I think the problems is inside the following code

App.Router.map(function(match) {
    match('/').to('index');
});     

App.IndexRoute = Em.Route.extend({
    connectOutlets: function(router) {
        router.get('applicationController').connectOutlet('sidebar', 'navigation');
        router.get('applicationController').connectOutlet('content');
    }       
});

Any suggestions what is wrong with this code ?

Also, in almost any example code I find on the web, I see that the App.Router is defined

App.Router = Em.Router.extend({
        enableLogging: true,

        root: Em.Route.extend({

            index: Em.Route.extend({
                route: '/',
                connectOutlets: function(router) {   
    .... etc ....

Because with ember-latest App.Router is already defined, I assume this is the old way of defining the Router ?


回答1:


I see in your fiddle that you are using pre-2. The newest version is pre-4, so I suggest you use that. http://emberjs.com/guides/ is up to date with pre-4.

I have created a fiddle and used your code as a starting point and ended up with what I think is what you tried to accomplish: http://jsfiddle.net/Energiz0r/9Xasr/4/

Basically the connectOutlet is replaced with

this.render('content', {into: 'index', outlet:'content');

And there are alot of other changes in the new route API. Again go through the guides at http://emberjs.com/guides/ to get the full understanding of it all.

Hope this helps!



来源:https://stackoverflow.com/questions/14605384/emberjs-how-to-use-connectoutlet

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