diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 842422ab37..e82f5d1298 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -48,17 +48,21 @@ "firstDayOfWeek": calendarFirstDayOfWeek }, onReady: function( selectedDates, dateStr, instance ){ + + /* When onReady is triggered, remove any existing "clear date" link */ + $(instance.input).parent().find('.flatpickr_wrapper_' + instance.input.id).remove(); + /* When flatpickr instance is created, automatically append a "clear date" link */ $(instance.input).find('~input.flatpickr:first') /* Add a wrapper element so that we can prevent the clear button from wrapping */ - .wrap("") + .wrap("") .attr("autocomplete", "off") .after( $("") .attr("href","#") .addClass("clear_date") .on("click", function(e){ e.preventDefault(); - instance.clear(); + instance.input.flatpickr().clear(); }) .addClass("fa fa-fw fa-times") .attr("aria-hidden", true)