$(document).ready(function(){ window.JQUERY_UI_DATE_PICKER_DEFAULTS = { dateFormat: Spree.translations.date_picker, dayNames: Spree.translations.abbr_day_names, dayNamesMin: Spree.translations.abbr_day_names, monthNames: Spree.translations.month_names, prevText: Spree.translations.previous, nextText: Spree.translations.next, oneLine: true, showOn: 'button', buttonImage: "<%= asset_path 'datepicker/cal.gif' %>", buttonImageOnly: true } window.JQUERY_UI_DATETIME_PICKER_DEFAULTS = Object.assign( {}, window.JQUERY_UI_DATE_PICKER_DEFAULTS, { currentText: Spree.translations.datetime_ui_current_text, closeText: Spree.translations.datetime_ui_close_text, timeText: Spree.translations.datetime_ui_time_text, timeFormat: 'HH:mm', controlType: 'select', stepMinute: 15 } ); $('.datetimepicker').datetimepicker(window.JQUERY_UI_DATETIME_PICKER_DEFAULTS); $('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; }); });