Skip to main content

Search and Top Navigation

#11060 open feature ()

Opened February 10, 2015 12:41PM UTC

Last modified February 10, 2015 01:41PM UTC

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.

Attachments (0)
Change History (1)

Changed February 10, 2015 01:41PM UTC by scottgonzalez comment:1

status: newopen
summary: Add an UI Datepicker onUpdate and fix the demoDatepicker: Add a change event
type: bugfeature