2
votes

I have a main view and a modal window which is a child view from the parent view.

The modal consist of a form which is submitted via ajax.

How do I render the parent view from the child view after submitting the form?

1

1 Answers

10
votes

The parent view can bind to notifications on the child view to know when the form was submitted. Then it can render itself:

On the parent view:

// Parent initialize
this.childView.on('formSubmitted', this.render, this);

// Parent removal
this.childView.off('formSubmitted', this.render, this);

On the child view:

// After form is submitted
this.trigger('formSubmitted');

The child will trigger a "formSubmitted" event and the parent's render function will be called.