jeudi 18 août 2016

Changing a component's property doesn't fire 'change' on other components

I have two components sideways in the same hierarchy (siblings). I am passing the model to both of them. I am changing the model data from a component, and want to catch all changes from the other one, but the components 'change' event fires only on the component which is used to change the value. It doesn't work in other components. How can I achieve this? I just want to communicate through the two components.

app/routes/applications.js

export default Ember.Route.extend({
    model() {
        return Ember.RSVP.hash({
            rejectFormData: {
                application_id: null,
                reject_reason: null,
                subject: '',
                body: ''
            }
        });
    }
});

app/templates/applications.hbs:




app/components/reject-dialog.js

export default Ember.Component.extend({
    change() {
        // this fires only when changed through this component
        // I want this to fire even when changed from other components
        alert('changed!');
    },
    actions: {
        rejectApplication(formData) {
            this.set('formData.application_id', 123);
        }
    }
});

app/components/applications-list.js

export default Ember.Component.extend({
    actions: {

        rejectApplication (application) {
            this.set('rejectFormData.application_id', application.Application.id);
        }
    }
});




Aucun commentaire:

Enregistrer un commentaire