2015-05-14 135 views
0

这是我的路线。当我使用另一个控制器的trasitionToRoute方法调用此路由时,出现错误。无法读取undefined TypeError的属性'connectOutlet':

这里是我的路由器:

App.AllSectionsRoute = Ember.Route.extend({ 

    renderTemplate: function() { 
     //this._super(); 

     this.render('fire', { outlet: 'fire', into: 'allSections' }); 

     this.render('gas', { outlet: 'gas', into: 'allSections' }); 

    } 
}); 

这里是我的模板:

<script type="text/x-handlebars" data-template-name="allSections"> 
     <hr/> 
     <hr/> 
     <div class='outletArea'> 
      {{outlet "fire"}} 
     </div> 
     <hr/> 
     <div class='outletArea'> 
      {{outlet "gas"}} 
     </div> 
    </script> 

如果我不叫this._super(controller, model);声明,当时我得到的connectOutlet of undefined错误。

但是当我调用这个语句,那么错误不会出来,但是我不得不渲染像“fire”和“gas”这样的模板“allsections”的额外模板。它将当前模板渲染到“allSections”中,但那是已经打开的模板。

请建议我,如果我错了.....

回答

1

不知道你在做什么其他,但我无法重现您的问题。 我创建了这个jsbin来模拟你的场景,它工作正常。我打电话this._super()寿:

App.AllSectionsRoute = Ember.Route.extend({ 
    renderTemplate: function() { 
    this._super(); 

    this.render('fire', { 
     into: 'allSections', 
     outlet: 'fire' 
    }); 

    this.render('gas', { 
     into: 'allSections', 
     outlet: 'gas' 
    }); 
    } 
}); 
+0

你是对的,但是当我打电话this._super()方法,然后在allSections模板渲染模板是当前打开的不是“气”和“火”。感谢编辑我的语法,并为我的英语不好而感到遗憾。为什么它呈现之前的模板而不是气体和火焰。这是我的问题。 –

+0

“以前的模板”是什么意思? – MilkyWayJoe

+0

Hi @MilkyWayJoe例如,如果我已经打开气体模板,然后执行此任务,则意味着当时在“allSections”中打开“gas”和“fire”,只有“gas”模板将在“allSections”所有部分的插座 –

相关问题