I suppose I could have one controller for the modal and another for updating the different sections.
Still, it looks like I will need to keep both controllers in the body.
I do feel like this is probably a common pattern for rails CRUD views; any recommendations would be appreciated!
modal view
<div class="modal-wrapper" data-reveal>
<div target="edit-modal.content">
<%= form_for venture_stage_path(@project),
remote: true,
data: {
action: 'ajax:success->edit-modal#onSaveSucess ajax:success->section#onUpdate',
section: 'ventureStage'
} do |f| %>
<!-- rendered form fields -->
<% end %>
</div>
</div>
section_controller.js
export default class extends Controller {
static targets = [
'ventureStage',
'location',
'highlights',
'oneLiner',
'desciription',
];
onUpdate(e) {
const [data, status, xhr] = e.details;
const currentTarget = `${e.currentTarget.dataset.section}Target`;
this[currentTarget].innerHTML = xhr.response;
}
}