2013-10-04 26 views
0

我真的只想渲染一個模板,這裏沒什麼特別的。正確的方式來使用不帶路由的使用餘燼的視圖

$(document).on('ready',function(){ 
    console.log('.foot rendering'); 

    var FooterView = Ember.View.extend({ 
     templateName: 'footer' 
    }).create().appendTo("body"); 

}); 

模板正確渲染,但調試器給了我以下錯誤:

DEPRECATION: Using the defaultContainer is no longer supported. [defaultContainer#lookup] 

有人能指出我朝着呈現此模板的正確方法?

UPDATE 它看起來就像直接使用把手模板是這裏的方式。

$(document).on('ready',function(){ 
    console.log('.foot rendering'); 
    var footTemplate = Handlebars.compile($("#footer").html()); 
    var footContext = {}; // ... 
    $("body").append(footTemplate(footContext)); 
}); 
+0

你當然不應該做一個jQuery的處理器中的任何灰燼邏輯。如果可能的話,請發佈您的應用和模板的其餘部分。 – Pavlo

回答

0

我認爲這是不使用燼沒有路由器是一個好主意。因爲路由器在連接插座時在視圖中設置容器。

如果你想使你的樣品工作,只是通過App.__container__到您的視圖容器屬性:

App = Ember.Application.create(); 

$(document).ready(function(){  
    console.log('.foot rendering'); 
    App.FooterView = Ember.View.extend({ 
     templateName: 'footer' 
    }).create({ 
     container: App.__container__ 
    }).appendTo("body"); 
}); 

但是,這不是一個很好的實踐。

有關默認容器棄用的討論是在這裏https://gist.github.com/stefanpenner/5627411

0

您可以使用部分幫助器來呈現您的模板。對於您的情況,請將以下代碼放在body標籤內。 {{partial "footer"}} 欲瞭解更多詳情,請參閱本emberjsdoc.

相關問題