jonthornton / Datepair.js

A javascript plugin for intelligently selecting date and time ranges, inspired by Google Calendar.
https://www.jonthornton.com/Datepair.js
359 stars 85 forks source link

`anchor:null` breaks `showDuration` #28

Closed jonthornton closed 9 years ago

jonthornton commented 9 years ago

Reposting issue mentioned in #27 by @dbinaz: Also, by adding anchor:null, showDuration on endtime does not work and neither does the option in this script

$("#EventStartTime").on("changeTime", function(){
        var that = $(this);
        $('#EventEndTime').removeAttr("disabled");
        $('#EventEndTime').timepicker(
          'option',{
            'minTime': $(that).val()
        });
        validateEventDate($("#EventDate").val());
    });
jonthornton commented 9 years ago

That's by design. The duration times are relative to the "anchor" time - if there's no anchor, it doesn't make sense to show a duration.

Regarding the changeTime handler: that code doesn't touch the Datepair.js plugin at all. Please post a ticket in the timepicker project: https://github.com/jonthornton/jquery-timepicker/issues

KrunchMuffin commented 9 years ago

So why does datepair affect the timepicker options? It should have no affect. I am telling timepicker to use starttime as the base for show duration in endtime.

jonthornton commented 9 years ago

The default behavior of Datepair is to set the minTime of non-anchor time input when the anchor time input is changed. If you'd like to manage the minTime yourself, you need to set the setMinTime option in Datepicker to null.

For what it's worth, by default Datepair uses starttime as the base for show duration in endtime. You should not have to do that manually. Without a working demo, I can't help much more.

KrunchMuffin commented 9 years ago

I wasn't using datepair before my requirement changed. Now I need to know if the endtime has spilled over to the next day. I can send you a URL, I just can't post it publicly.

jonthornton commented 9 years ago

This is an open source project - if I help you with something, it needs to be out in the open so other people can benefit from it. Otherwise I'm just consulting for you for free.

Find a way to post a jsFiddle or some other demo if you'd like help.