mardi 16 juin 2015

When creating a new data object in Ember that relies on another object how do you pass it along?

I am on a page where I can see a specific customer, part of my router.js is:

this.route('customers');
this.route('customer', {path: "customers/:customer_id"});
this.route('customer.order.create', { path: "customers/:customer_id/order/create" });

customer.order.create needs to load in my main view and so is not nested. An order 'has a' customer.

I've setup my /customer/order/create controller to have

needs: "customer"

I want to access the customer in my /customer/order/create.hbs template like this:

<h3>New Order for {{controllers.customer.name}}</h3>

When I end up creating the order I will also want to set newOrder.customer = customer.

customer.hbs links like so

<div>
  {{#link-to 'customer.order.create' model}}Create Order{{/link-to}}
</div>

Currently {{controllers.customer.name}} renders nothing, what piece of the puzzle am I missing to get to the customer in my order/create route?

Or putting it more generally, what route/controller/etc code do I need when I have a parent object which belongs to my child object in a /parentObject/parent_id/childObject/create type scenario.




Aucun commentaire:

Enregistrer un commentaire