EmberJs:如何使用connectOutlet [英] EmberJs: how to use connectOutlet

查看:565
本文介绍了EmberJs:如何使用connectOutlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的测试,我尝试使用connectOutlet。但是,渲染不是很多。以下是我的测试代码: http://jsfiddle.net/jeanluca/53dpA/



只是总结应用程序。我认为问题出在下面的代码中:

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

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

任何建议这段代码有什么问题?



另外,几乎任何在网页上找到的示例代码中,我看到App.Router被定义为

 应用程序.Router = Em.Router.extend({
enableLogging:true,

root:Em.Route.extend({

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

我在你的小提琴中看到你正在使用pre-2,最新版本是前4,所以我建议你使用它。 http://emberjs.com/guides/ 是最新版本之前的4。



我创建了一个小提琴,并使用你的代码作为起点,最终结束了我认为是你试图完成的: http://jsfiddle.net/Energiz0r/9Xasr/4/



基本上将connectOutlet替换为

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

新路由API中还有其他更改。再次参阅 http://emberjs.com/guides/ 上的指南,以全面了解这一切



希望这有帮助!


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 ?

解决方案

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!

这篇关于EmberJs:如何使用connectOutlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆