vendredi 29 juillet 2016

Ember - Bind a form to new ember object

I have a model A which has many model B. In my show route I return an object of model A like

model: function(params) {
    return this.get('store').find('model-A', params.model_A_id);
}

I am trying to show a form inside an ember-modal-dialog in the above show route's template to create/save an object of model B. Everytime the user presses a button, the modal would show up with the form and on clicking Create the form data would be passed to createModelB() action in my route.

Eveytime the user presses the button to show modal, I need a way to create an empty object of model B which will hold the form data and pass it to my action. If the user closes the modal without creating an object, I need to delete the empty object.

Where/How would I create this empty object for holding the form data?

In short,

<form >
  
</form>

How do I create an emptyModelBObject everytime user presses a button?




Aucun commentaire:

Enregistrer un commentaire