lundi 25 mai 2015

ember select change model property only on button click

I have an ember Select that is bound to a property of the model in a modal dialog.

I want the model property to change only if the user clicks OK (and gets reverted if he clicks cancel).

How can I do that?

edit-session-modal.hbs:

{{#modal-dialog title='Change status (select empty to return to original status)' ok='save' close='closeModal'}}
    <form {{action 'ok' on='submit' target=view}}>
        <div class="form-group">
            <label>Status</label>
          {{view "select" content=sessionStatuses selection=model.status}}
        </div>
    </form>
{{/modal-dialog}}

controllers/edit-session-modal.js:

import Ember from 'ember';

export default Ember.Controller.extend({
  actions: {
    close: function() {
      return this.send('closeModal');
    }
  },
  sessionStatuses: ['', 'SUCCESS', 'FAILURE', 'RUNNING'],
  selectedStatus: "model.status"
});




Aucun commentaire:

Enregistrer un commentaire