const modalElement = document.getElementById('remote_modal'); modalElement.addEventListener('hidden.bs.modal', event => { var newTurboFrameTag = document.createElement("turbo-frame"); newTurboFrameTag.setAttribute("id", "remote_modal"); modalElement.replaceWith(newTurboFrameTag); });