trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

set minDate dynamically => no time set, only date #705

Closed eltigre4jc closed 10 years ago

eltigre4jc commented 10 years ago

Hi! I saw that are more issues more or less related to this one. My scenario is like this: 2 vb net controls (DateFrom and DateTo) with a textBox and datepickers. 1 option: ShowTime. If set to false, I use datepicker, else i use datetimepicker

I set the date of the first control to be the minDate for the second through a javascript

$('#To' ).datepicker('option', 'minDate', $('#From').datetimepicker('getDate'));

When I open the second control with datetimepicker, only the date, and NOT the time is set..

I tried to look in the plugin, the follow with the debugger, but I cannot understand where do I have to change and what do I have to change to make it work. Basically, half of the action is done, it remains the part with the time

Maybe we can have a fix for this or at least a workaround... Please help. Thank you :)

robocub commented 10 years ago

try this as a workaround:

var to = $('#To').val();
$('#To').datepicker('option', 'minDate', $('#From').datetimepicker('getDate')).val(to); 
eltigre4jc commented 10 years ago

doesn't work... it seems that this is a serious bug with minDate and maxDate

  1. Set mindate dinamically for second datetimepicker (see comment #1)
  2. open second datetimepicker and select last day of month (which is accessible) and then click on "Done"
  3. Nothing happens (I made a picture to see how the functions are called after you click on "Done")

scenario

daniel-k commented 10 years ago

I also ran into this and it seems that you have to set minDateTime and maxDateTime. So in your case it would be:

$('#To' ).datepicker('option', 'minDateTime', $('#From').datetimepicker('getDate'));

But either way there is some inconsistency, because when you set minDate when initializing the datetimepicker the time is also set (which led me to the conclusion that minDate equals minDateTime, therefore the confusion)

trentrichardson commented 10 years ago

It sounds like this original issue has been fixed in the dev branch, so I am closing this issue. Please reopen if it is not.