diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index ed7288660..16b56827d 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -43,9 +43,6 @@ // forms with clicking on links outside form in cases when other than // GET method is used. -// eslint-disable-next-line no-unused-vars -var formatJS = $('body').data('datetime-picker-format-date-only'); - function initFormSubmitLinks(el) { el = el || $(document.body); diff --git a/app/assets/javascripts/dashboard/calendar.js b/app/assets/javascripts/dashboard/calendar.js index c52a2d5d0..d200467eb 100644 --- a/app/assets/javascripts/dashboard/calendar.js +++ b/app/assets/javascripts/dashboard/calendar.js @@ -83,6 +83,8 @@ var DasboardCalendarWidget = (function() { }; }()); +var formatJS; $(document).on('turbolinks:load', function() { DasboardCalendarWidget.init(); + formatJS = $('body').data('datetime-picker-format'); }); diff --git a/app/assets/javascripts/global_activities/date_picker.js b/app/assets/javascripts/global_activities/date_picker.js index 1c9db9b03..7f55977ab 100644 --- a/app/assets/javascripts/global_activities/date_picker.js +++ b/app/assets/javascripts/global_activities/date_picker.js @@ -1,10 +1,11 @@ -/* global I18n formatJS */ +/* global I18n */ (function() { $('.datetime-picker-container').each(function() { const id = $(this).data('id'); if (id) { const dt = $(`#calendar-${id}`); const useCurrent = $(this).data('use-current'); + const formatJS = $(this).data('datetime-picker-format'); dt.datetimepicker({ useCurrent, ignoreReadonly: true, locale: I18n.locale, format: formatJS }); diff --git a/app/views/global_activities/_date_picker.html.erb b/app/views/global_activities/_date_picker.html.erb index b0cd19f04..d26dbbd07 100644 --- a/app/views/global_activities/_date_picker.html.erb +++ b/app/views/global_activities/_date_picker.html.erb @@ -1,7 +1,8 @@