2012-08-04 10 views
2

我第一次嘗試了Ember.js,大致遵循了Ember.js指南,但我遇到了以下問題。event.context使用{{#each ...}(undefined)時未被{{action ...}}設置

相關代碼: https://gist.github.com/3257657(完整的Rails應用程序,請參見:https://github.com/basveeling/ember-test

語境: 我運行最新的餘燼,軌道建設與1.0搶鮮ember.js。我爲post模型使用了ember-data。

除了由{{action showPost context="post" href=true}}創建的hrefs具有未定義的ID(#/posts/undefined)之外,幾乎所有應用程序都可以在此應用程序中使用。 此外,傳遞給showPost操作的jQuery事件沒有上下文屬性(它有一個視圖屬性)。

我是以這種錯誤的方式去做的,還是我可能偶然發現了預發佈中的錯誤?

編輯:這可能與Url contains 'undefined' instead of id after navigating back from 'edit' to 'show'

回答

7

嘗試改變{{action showPost context="post" href=true}}{{action showPost post href=true}}

1.0搶鮮改變了動作助手。

更多信息:https://github.com/emberjs/ember.js/commit/83b7a61a892e55423cf1e66f606b13435bcab8f0

+0

只是嘗試這樣做:它更新在href(例如,現在呈現給'...'),這似乎不錯,但點擊時,它指向#/職位/未定義出於某種原因。有任何想法嗎? 編輯:woops,忘記重置'showPost:function(router,event){...'回到showPost:Ember.Route.transitionTo('posts.show'),.謝謝你的幫助! – Bas 2012-08-04 13:36:11

+2

你甚至可以發送幾個上下文對象。您將在event.contexts數組中包含它們 – 2012-08-04 17:42:34

相關問題