$(document).ready(function() { var onClickButtons = function(index, fp) { var date; switch (index) { case 0: date = new Date(); break; } fp.setDate(date, true); } window.FLATPICKR_DATE_DEFAULT = { altInput: true, altFormat: Spree.translations.flatpickr_date_format, dateFormat: "Y-m-d", locale: I18n.locale, plugins: [ ShortcutButtonsPlugin({ button: [{ label: Spree.translations.today }], label: "or", onClick: onClickButtons }), labelPlugin({}) ] } window.FLATPICKR_DATETIME_DEFAULT = Object.assign( {}, window.FLATPICKR_DATE_DEFAULT, { altInput: true, altFormat: Spree.translations.flatpickr_datetime_format, dateFormat: "Y-m-d H:i", enableTime: true, time_24hr: true, plugins: [ ShortcutButtonsPlugin({ button: [{ label: Spree.translations.now }], label: "or", onClick: onClickButtons }), labelPlugin({}) ] } ); flatpickr(".datetimepicker", window.FLATPICKR_DATETIME_DEFAULT); $('a.close').click(function(event){ event.preventDefault(); $(this).parent().slideUp(250); }); // Spree locates hidden with prev(), which with our current version of jQuery // does not locate the hidden field, resulting in the delete failing. This // handler updates the hidden field, fixing the problem. $('body').on('click', 'a.remove_fields', function() { $(this).next("input[type=hidden]").val("1"); return false; }); });