2013-05-08 20 views
0



有誰知道如何鏈接路線說PostRoute(名稱已更改從原始應用程序),具有等效控制器PostController與非標準視圖說RC 3中的BlogPostView?我正在使用Ember Animated插座和視圖,但是就RC 1涉及的路線/動畫而言,沒有做任何額外的處理,但RC 3給出了此錯誤)。在RC 1中,只是聲明如此工作,如何修改路由定義以使其與RC 3一起工作?我嘗試用RC 3重新構建ember-animated-outlet.js,但是同樣的結果(希望它可能是用RC-3前餘燼版本構建的)?無法鏈接非標準視圖與Ember路由(RC 3)和Ember AnimatedView

App.Router.map(function(){ 
... 
this.route('post'); 
... 
} 

<script type="text/x-handlebars" data-template-name="application"> 
    {{animatedOutlet name="main"}} 
</script> 

<script type="text/x-handlebars" data-template-name="post"> 
    {{view App.BlogPostView}} 
</script> 

沿着我得到這個錯誤

Ember.AnimatedContainerView can only animate non-virtual views. You need to explicitly define your view class. 

我打過電話爲this.render( '博文')中renderTemplate視圖,以便找到BlogPostView,但在調試這樣的調用時返回「undefined」。

我發現郵政路線的視圖被標識爲虛擬。如何告訴Ember對於這條路線,使用這個非虛擬的視圖,以便它停止抱怨。我BlogPostView看起來是這樣的:

App.BlogPostView = Ember.View.extend({ 
    template: $.template('blog_post'), 
    didInsertElement: function() { 
    ... 
    } 
    ... 
}); 

謝謝
水稻

+0

請問你'BlogPostView 「看起來像? – intuitivepixel 2013-05-08 11:16:14

+0

你能解釋一下你的「長相」是什麼意思?我擴展了Ember.View.extend(這裏顯示的類的名稱已經從原來的版本更改過) – Paddy 2013-05-09 15:32:58

+0

「看起來像」我的意思是在問題周圍顯示更多代碼示例是一種常見做法,因此社區可以更輕鬆地提供幫助: ) – intuitivepixel 2013-05-09 15:35:29

回答

0

我猜的錯誤來自確切此行template: $.template('blog_post')。 作爲statet在docs

的App.AnimatedContainerView的所有子視圖需要加以明確定義,因爲動畫僅與非虛擬視圖的工作。這意味着,如果你有一個路線叫invoices.show,你希望動畫進去,你需要定義視圖是:App.InvoicesShowView = Ember.View.extend()

什麼docs做不明確的狀態是你需要爲你的視圖定義一個模板,因此,因爲你不能爲動畫插座使用預編譯的模板,所以你必須在早期定義它們。這意味着如果你有一個BlogPostView,你需要一個已經定義的blogPost模板來備份BlogPostView。然後

你的看法會導致類似:

App.BlogPostView = Ember.View.extend({ 
    template: 'blog_post' 
}); 

和模板備份的觀點一樣,:

<script type="text/x-handlebars" data-template-name="blog_post"> 
    ... 
</script> 

讓我知道這是否有助於

+0

我會試試這個,讓你知道。我最初的嘗試沒有成功,可能是我的代碼有問題,不知道如何發佈整個JSBin,因爲它有點複雜的代碼。有沒有其他的指針來找出根本原因?無論如何,如果我們不能使用預編譯的模板,這是否會導致性能下降?我已經看到我的頁面花了一點時間來加載使用templateName而不是預編譯模板的更改。 – Paddy 2013-06-04 04:49:35