Skip to content

Using setDate on another input changes datetimepicker focus to other input #101

@midnightmonster

Description

@midnightmonster

This is probably related to #56, but I have two datetimepickers, one for the start of an event, the other for the end. When the date/time is selected on the first one, I want to also set the second one to one hour later.

var $start = $('input[name=begin_dt]');
var $end = $('input[name=end_dt]');
$start.datetimepicker({
  onSelect:function(){
    var date = $start.datepicker("getDate");
    date.setHours(date.getHours()+1);
    $end.datepicker("setDate",date);
  }
});
$end.datetimepicker({});

With this code, focusing the first field and setting the date causes the second field also to be set to one hour past the first field value, but the 'Time: X:XX' display makes a visible jump to momentarily show the second time before switching back to the first time.

That was setting the date only. If I then use a time slider (or use a time slider before changing the date), as soon as I let go of the mouse, the first and second field are both set correctly, but the datetimepicker immediately becomes associated with the second field instead of the first: the time switches to the 1-hour-ahead value, and all changes to date or time until closing the widget affect the second field instead of the first. The location of the datetimepicker does not change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions