I have a JS code in which when you change a field it calls a search routine. The problem is that I can’t find any jQuery events that will fire when the Datepicker updates the input field.
For some reason, a change event is not called when Datepicker updates the field. When the calendar pops up it changes the focus so I can’t use that either. Any ideas?
You can use the datepicker’s
onSelectevent.Live example:
Unfortunately,
onSelectfires whenever a date is selected, even if it hasn’t changed. This is a design flaw in the datepicker: It always firesonSelect(even if nothing changed), and doesn’t fire any event on the underlying input on change. (If you look in the code of that example, we’re listening for changes, but they aren’t being raised.) It should probably fire an event on the input when things change (possibly the usualchangeevent, or possibly a datepicker-specific one).If you like, of course, you can make the
changeevent on theinputfire:That will fire
changeon the underlyinginputfor any handler hooked up via jQuery. But again, it always fires it. If you want to only fire on a real change, you’ll have to save the previous value (possibly viadata) and compare.Live example: