event.context not set by {{action …}} when using {{#each …} (undefined)

ぃ、小莉子 提交于 2019-12-21 21:06:19

问题


I'm trying out Ember.js for the first time by roughly following the Ember.js guide, but I'm running into the following problem.

Relevant code: https://gist.github.com/3257657 (for complete rails app, see: https://github.com/basveeling/ember-test)

Context: I'm running the latest ember-rails build with the 1.0 prerelease ember.js. I'm using ember-data for the post model.

Almost everything works in this app, except that the hrefs created by {{action showPost context="post" href=true}} have an undefined id (#/posts/undefined). Furthermore, the jQuery event passed to the showPost action doesn't have a context property (it does have a view property).

Am I going at this the wrong way, or have I perhaps stumbled on a bug in the prerelease?

edit: this might be related to Url contains 'undefined' instead of id after navigating back from 'edit' to 'show'


回答1:


Try change {{action showPost context="post" href=true}} to {{action showPost post href=true}}

The 1.0 prerelease has changed the action helper.

More info: https://github.com/emberjs/ember.js/commit/83b7a61a892e55423cf1e66f606b13435bcab8f0



来源:https://stackoverflow.com/questions/11808995/event-context-not-set-by-action-when-using-each-undefined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!