lundi 24 août 2015

Ember js submit embeded data

I have an ember js application. I have two models ( Alert, Ticket ) with the following association:

ticket: DS.belongsTo 'ticket', async: true

Now on alerts.show, I create a new ticket in the route:

setupController: ( controller, model )->
  @._super(controller, model)
  ticket = controller.get('store').createRecord( 'ticket' )
  model.set( 'ticket', ticket )
  controller.set( 'ticket', ticket )

In the template ( alerts.show ) I have a form for creating a and submitting a new ticket. Here is my createTicket action ( in the controller ):

createTicket: ->
  @set( 'content.data.ticket', @get( 'content.ticket' ) )
  @get('content').save().then (data)=>

The problem is that the alert data is submitted ( as expected), but the ticket data is not. I need to submit both ( alert and ticket data ) and the association MUST be as it is now ( alert belongsTo ticket, async )

Any suggestions?




Aucun commentaire:

Enregistrer un commentaire