Opened 13 years ago

Closed 11 years ago

#5473 closed bug (fixed)

Datepicker: Date range demo bug when clearing date

Reported by: mattac Owned by:
Priority: minor Milestone: 1.9.1
Component: ui.datepicker Version: 1.8
Keywords: Cc:
Blocked by: Blocking:

Description

I'd like to suggest an improvement to the date range limiting implementation listed here:

http://jqueryui.com/demos/datepicker/#event-search

The current implementation has a bug. If a date is selected in one field and then cleared out, the date limiting will remain for the other field. Using an onClose handler rather than onSelect enables removing the min/maxDate setting on the other field.

See the following:

    onClose: function(selectedDate) {
        if (selectedDate) {
            var option = this.id == "from" ? "minDate" : "maxDate";
	    var instance = $(this).data("datepicker");
            var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
	    dates.not(this).datepicker("option", option, date);
        }
        else {
            dates.not(this).datepicker("option", option, null);
        }
    }

Change History (2)

comment:1 Changed 11 years ago by Scott González

Milestone: TBD1.9.1
Summary: "Event Search" documentation bug fixDatepicker: Date range demo bug when clearing date

comment:2 Changed 11 years ago by Scott González

Resolution: fixed
Status: newclosed

Datepicker demo: Fixed date range restriction when clearing dates. Fixes #5473 - Datepicker: Date range demo bug when clearing date.

Changeset: a50516f77e82206f2d1f4188c9f5a242442ace09

Note: See TracTickets for help on using tickets.