Opened 4 years ago

Last modified 4 years ago

#11060 open feature

Datepicker: Add a change event

Reported by: pgpp05 Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.11.2
Keywords: Cc:
Blocked by: Blocking:

Description

Datepicker has no onChange/onUpdate handler (nor any equivalent event). I'm explaining: Go to http://jqueryui.com/datepicker/#date-range Click on the first field, hit Escape, then enter a date. Press Tab. The second datepicker boudary is not set as expected.

This is simply because relying on onClose handler is not sufficient. It's possible to change the widget value without triggering onClose. Uning a not-hidden altField we can easily observe that there is a real-time process that keeps the widget input, the widget internal value and the alt field value in sync. This process should call an onUpdate handler to avoid the problem of relying on onClose.

We could listen .on('change') handler on the input, and I think it's the right way for the demo I linked above, but this is not always sufficient for other applications as it's not realtime, and do not reflect the .on('change') event triggered on the altField for instance.

So I propose to add a onUpdate handler called every time the widget updates it's internal value (same logic as updating the altField).

Why onUpdate and not onChange? Because 'change' is usually triggered when the input is blurred and it's value actually changed. onUpdate is semantically closer to onSelect (or like slider stop event), since it's an ui update and not (yet) a real value 'change'.

You should fix the demo at http://jqueryui.com/datepicker/#date-range, either using onUpdate or, better, .on('change') on the input.

Change History (1)

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

Status: newopen
Summary: Add an UI Datepicker onUpdate and fix the demoDatepicker: Add a change event
Type: bugfeature
Note: See TracTickets for help on using tickets.