Cracker
Cracker

Reputation: 1768

EmberJS linkTo works but not transitionTo

I have routes defined as below

  this.resource('projects', function() {
    this.resource('project', { path: ':project_id'}, function() {
        this.route('details');
        this.route('members');
    });     
  });

projects displays a list of projects. On clicking a project I transition to project.details in ProjectsIndexRoute. But the model is not set to the clicked project. However if I create a link using linkTo to project.details then everything works.

See http://jsbin.com/ELaxigE/3/edit

Upvotes: 0

Views: 156

Answers (3)

intuitivepixel
intuitivepixel

Reputation: 23322

Both answer till now where correct from @LukeMelia & @JonathanTran, that you need to provide a model for your action call, but no one provided actually a proof for it, here it is: http://jsbin.com/ELaxigE/18/edit.

Hope it helps.

Upvotes: 0

Luke Melia
Luke Melia

Reputation: 8389

Your event is expecting to be passed a project, but you are not specifying one in the action helper. Instead of {{action 'open' on='click'}}, you need to do:

{{action 'open' this on='click'}}

(Also, on='click' is unnecessary. It is the default behavior.)

Upvotes: 1

Jonathan Tran
Jonathan Tran

Reputation: 15276

You're missing the model. If you were to log c in your open action handler, you would see that it's undefined. Change this in your template ...

{{action 'open' on='click'}}

to this...

{{action 'open' this on='click'}}

Upvotes: 1

Related Questions