From bcdd05b80a81159c671ae38ede1d775151d2d770 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Fri, 12 Jan 2024 09:11:46 -0500 Subject: [PATCH] Improve fix by assigning variables from event.detail --- .../javascripts/avalon_timelines/timelines.js.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/avalon_timelines/timelines.js.coffee b/app/assets/javascripts/avalon_timelines/timelines.js.coffee index e7367f8cdc..87b115d403 100644 --- a/app/assets/javascripts/avalon_timelines/timelines.js.coffee +++ b/app/assets/javascripts/avalon_timelines/timelines.js.coffee @@ -65,17 +65,19 @@ $('#copy-timeline-form').submit( ) $('#copy-timeline-form').bind('ajax:success', - (event, data, status, xhr) -> - if (data?.errors) + (event) -> + [data, status, xhr] = event.detail + if (data.errors) console.log(data.errors.title[0]) else if (submit_edit) - window.location.href = event.detail[0].path + window.location.href = data.path else if ( $('#with_refresh').val() ) location.reload() ).bind('ajax:error', - (e, xhr, status, error) -> + (event) -> + [data, status, xhr] = event.detail console.log(xhr.responseJSON.errors) )