2

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'

Community
  • 1
  • 1
Bas
  • 834
  • 6
  • 15

1 Answers1

7

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

horlick
  • 171
  • 3
  • Just tried this: it updates the href (e.g. it now renders to `...`), which seems good, however when clicked, it points to #/posts/undefined for some reason. Any ideas? Edit: woops, forgot to reset the `showPost: function(router,event){...` back to showPost: Ember.Route.transitionTo('posts.show'),. Thanks for your help! – Bas Aug 04 '12 at 13:36
  • 2
    You can even send several context objects now. You will have them in the event.contexts array – sly7_7 Aug 04 '12 at 17:42