2013-04-02 34 views
1

我有一點與ember.js的麻煩。Ember.js查看沒有正確地傳遞上下文到路由器,甚至

我有以下代碼,它可以在路由器中正確調用事件來創建筆記本。但是,它不會傳遞筆記本上下文,它不確定。我一直在尋找幾個小時來嘗試找到解決方案。

我發現thisthis,這是有幫助的,但我不完全確定我在正確的軌道上。我錯過了什麼嗎?

路線

App.NotebooksNewRoute = Ember.Route.extend 
    model: -> 
     App.Notebook.createRecord() 
    events: 
     create: (notebook) -> 
      #persist notebook 

形式

{{#with content}} 
    <form {{action create content on="submit" }} > 
     <div> 
      {{view Ember.TextField placeholder="Enter a title" valueBinding="title" }} 
     </div> 

     <div> 
      {{view Ember.TextArea placeholder="Notes" valueBinding="description" }} 
     </div> 

     <button type="submit">Create</button> 
    </form> 
{{/with}} 

回答

1

我缺少的東西?

變化{{action create content on="submit" }}{{action create this on="submit" }}

爲什麼?

當您使用把手幫手{{#with}}時,封閉塊將在指定變量的上下文中呈現。所以{{#with content}}後,this是什麼content是,你可以像titledescription,而不是直接content.titlecontent.description

+0

完美的作品訪問特性,它現在是有道理的,謝謝! – JeremyC

相關問題