2013-03-19 57 views
1

我在製作一個通過rails管道預編譯Handlebars資產的ember-rails應用程序。一切都通過bundle update更新到最新版本。ember-rails&handlebars:指定的templateName對於一個視圖不存在,但對所有其他視圖不存在

當我們加載索引,餘燼數據不被渲染到列表中,儘管(應用程序/視圖/演出/ index.html.erb):

<h1>Gigs</h1> 

<script type="text/x-handlebars"> 
    {{ view App.ListGigsView }} 
</script> 

<script type="text/javascript"> 
    $(function() { 
    App.gigsController.loadAll(<%= @gigs.to_json.html_safe %>); 
    }); 
</script> 

所以,我查了ListGigsView,這包含以下(應用程序/資產/ Java腳本/應用/視圖/演出/ list.js):

App.ListGigsView = Ember.View.extend({ 
    templateName: 'app/templates/gigs/list', 
    gigsBinding: 'App.gigsController', 

    showNew: function() { 
    this.set('isNewVisible', true); 
    }, 

    hideNew: function() { 
this.set('isNewVisible', false); 
    }, 

refreshListing: function() { 
    App.gigsController.findAll() 
    } 

}); 

好像TEMPLATENAME指向罰款(這是,比方說,new.js類似)。然而,瀏覽器控制檯(谷歌的Chrome版本25.0.1364.172)保持返回以下:

Uncaught Error: assertion failed: You specified the templateName app/templates/gigs/list for <App.ListGigsView:ember194>, but it did not exist.

這裏是一個應用程序/資產/ Java腳本/應用/模板/演出/ list.handlebars文件:

<table> 
    <thead> 
    <tr> 
     <th>ID</th> 
     <th>Name</th> 
    </tr> 
    </thead> 
    <tbody> 
    {{#each gigs}} 
    {{view App.ShowGigView gigBinding="this"}} 
    {{/each}} 
{{#if isNewVisible}} 
    <tr> 
     <td>*</td> 
     <td> 
     {{view App.NewGigView}} 
     </td> 
    </tr> 
    {{/if}} 
    </tbody> 
</table> 
<div class="commands"> 
    <a href="#" {{action "showNew"}}>New Gig</a> 
    <a href="#" {{action "refreshListing"}}>Refresh Listing</a> 
</div> 

爲什麼模板不能渲染?在控制檯中運行Ember.TEMPLATES返回所有其他視圖模板鏈接完好:

> Ember.TEMPLATES 
=> Object {app/templates/gigs/edit: function, app/templates/gigs/event: function, app/templates/gigs/show: function, application: function} 

,但不是一個list。爲什麼這個模板是AWOL?

Ember.VERSION:1.0.0-RC.1 ember.js:339 Handlebars.VERSION:1.0.0-

  • 僅供參考,我下面根據瀏覽器控制檯正在運行rc.3 ember.js:339 jQuery.VERSION:1.9.1

- 編輯:我剛纔已經發現,包括車把參考事件視圖index.html.erb導致該模板消失:

<h1>Gigs</h1> 

<script type="text/x-handlebars"> 
    {{ view App.ListGigsView }} 
</script> 

<script type="text/x-handlebars"> 
    {{ view App.EventView }} 
</script> 

<script type="text/javascript"> 
    $(function() { 
    App.gigsController.loadAll(<%= @gigs.to_json.html_safe %>); 
    }); 
</script> 

這是爲什麼發生?我該如何避免它?

回答

2

app/templates/默認情況下從模板名稱中剝離。試試gigs/list

0

對我來說,它在剝離出templates(例如, app/gigs/list

相關問題