Search and Top Navigation
#8066 open feature ()
Opened January 27, 2012 10:19PM UTC
Last modified June 24, 2014 11:41PM UTC
datepicker setDate should trigger onSelect
Reported by: | sprugman | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.datepicker | Version: | 1.8.17 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If I have an event handler onSelect, I want it to fire when I change the selection via setDate. Here's a fiddle that demonstrates it not happening.
Attachments (0)
Change History (9)
Changed May 23, 2012 06:34AM UTC by comment:1
Changed June 26, 2012 01:22AM UTC by comment:2
type: | enhancement → feature |
---|
Changed October 03, 2012 05:32PM UTC by comment:3
Just wanted to add that as long as you don't need the first parameter (the date as a string), then an alternative workaround is to add a standard jQuery 'change' handler to foo that calls the same function that datepicker's onSelect does.
Then it could be done by
foo.datepicker('setDate', newDate); foo.change();
Not ideal by any measure, I actually like enbergj's workaround better as it keeps it all in onSelect, but this way may be easier for other developers to remember if you are working on a team.
Changed October 11, 2012 02:43PM UTC by comment:4
milestone: | 1.9.0 → 1.11.0 |
---|
Changed October 19, 2012 10:19PM UTC by comment:5
status: | new → open |
---|
Changed December 12, 2012 12:55AM UTC by comment:6
_comment0: | enbergj's method didn't work for me because my onSelect handler needed access to the inst object that is apssed internally to that event handler. I needed to be able to pass get the internal datepicker instance so I made a function to get it. \ \ Function to get the internal instance object of a datepicker element: http://jsfiddle.net/eG95A/ \ \ I believe there has to be a better way, but if you just need something that'll do the job, this is it until you find something better. → 1355273785821805 |
---|---|
_comment1: | enbergj's method didn't work for me because my onSelect handler needed access to the inst object that is passed internally to that event handler. I needed to be able to pass get the internal datepicker instance so I made a function to get it. \ \ Function to get the internal instance object of a datepicker element: http://jsfiddle.net/eG95A/ \ \ I believe there has to be a better way, but if you just need something that'll do the job, this is it until you find something better. → 1355273856383016 |
enbergj's method didn't work for me because my onSelect handler needed access to the inst object that is passed internally to that event handler. I needed to be able to pass get the internal datepicker instance so I made a function to get it.
Function to get the internal instance object of a datepicker element: http://jsfiddle.net/eG95A/2
I believe there has to be a better way, but if you just need something that'll do the job, this is it until you find something better.
Changed February 28, 2013 04:51PM UTC by comment:7
_comment0: | See this stackoverflow thread: http://stackoverflow.com/questions/2155485/jquery-datepicker-cant-trigger-onselect-event-manually \ \ $(".ui-datepicker-current-day").trigger("click"); \ \ is way more simple, though relying on the class used by jquery ui for the current day in calendar → 1362070312713452 |
---|
See this stackoverflow thread: http://stackoverflow.com/questions/2155485/jquery-datepicker-cant-trigger-onselect-event-manually
$(".ui-datepicker-current-day").trigger("click");
is way more simple, though relying on the class used by jquery ui for the current day in calendar
Changed September 25, 2013 05:02AM UTC by comment:8
Has there been any progress on this. It seems like a reasonable functionality. I couldn't believe that this wasn't default behavior until I verified it.
Changed June 24, 2014 11:41PM UTC by comment:9
milestone: | 1.11.0 → none |
---|
This is actually quite important, since there seems to be no SANE way to programmatically trigger the onSelect callback.
For example in my case, I'm using a Yii widget that wraps around jQuery UI datepicker, listens for the onSelect and updates the selected date in an input field to be submitted. I then use the setDate callback from JavaScript to update the selected date on an "end date" datepicker if the user selects a date past the end date from a "start date" datepicker. Now what I have to do is: