JQuery Datepicker onSelect issue

Rob Huzzey
Airport Cafe
1 min readNov 14, 2014

--

After some debugging we have discovered that the JQuery Datepicker UI plugin has a problem if you use the ‘onSelect’ method:

https://gist.github.com/robhuzzey/bd8f3486f8a7258b6ab3

JQuery Datepicker will now not fire the change event on the input element (the bug is documented here: http://bugs.jqueryui.com/ticket/7654).

In the above ticket, a ‘sloppy workaround’ was proposed, we tried it & it works:

https://gist.github.com/robhuzzey/42ce959282cfc4eadf20

What is happening here is that we are now saying “when datepicker closes, fire a change event”. This effectively is deferring the change event to when the user chooses a date (which trigger the close event) or actually closes the datepicker.

This potentially could cause a problem if you didn’t want your code inside the onSelect to execute when the datepicker closes but other than this, the workaround is sound.

Rob Huzzey & Emily Rumbelow (originally published 08/01/13)

--

--