<% # Remove the modal if it already exists %> $("#edit_broadcast_recording_modal").remove(); <% # Create and show the modal %> $("body").append("<%= j render(partial: 'edit_broadcast_recording_modal', locals: { project: @project, broadcast: @broadcast, recording: @recording }) %>"); $("#edit_broadcast_recording_modal").modal("toggle");