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

datetimepicker always showing all controls, ignores "show*" options set to false #830

Closed acid-reign closed 8 years ago

acid-reign commented 8 years ago

I recently upgraded to 1.5.3 (from 1.4.3 to fix to another bug where the default time value was truncated) I have a pair of date/time fields used in a filter form, both dialogs are showing all of the controls. But it should only show calendar + hour & minute. Here is my original code:

/*
 * Date Range
 */
$('#filter_start').datetimepicker({
    dateFormat: "yy-mm-dd",
    timeFormat: "HH:mm",
    showSecond: false,
    showMillisec: false,
    showMicrosec: false,
    showTimezone: false,
    changeMonth: true,
    changeYear: true,
    hourGrid: 3,
    minuteGrid: 10,
    onClose: function( selectedDate ) {
        $('#filter_end').datetimepicker( "option", "minDate", selectedDate );
    }
});

$('#filter_end').datetimepicker({
    dateFormat: "yy-mm-dd",
    timeFormat: "HH:mm",
    showSecond: false,
    showMillisec: false,
    showMicrosec: false,
    showTimezone: false,
    changeMonth: true,
    changeYear: true,
    hourGrid: 3,
    minuteGrid: 10,
    onClose: function( selectedDate ) {
        $('#filter_start').datetimepicker( "option", "maxDate", selectedDate );
    }
});

Note: I originally did not use the show* options, as I expected the detection mentioned on the documentation to only enable the hour & minute controls, based on the format "HH:mm", when that did not work I attempted to force the issue, but this also had no effect.

I have also (after recently discovering the option...) tried using the datetimeRange example:

$.timepicker.datetimeRange(
    $('#filter_start'),
    $('#filter_end'),
    {
        dateFormat: "yy-mm-dd",
        timeFormat: "HH:mm",
        hourGrid: 3,
        minuteGrid: 10,
    }
);

I tried the above with, and without, the "show*" options, and still all controls are shown.

browser is Firefox 39.0 jQuery is 1.11.0 jQuery UI is 1.11.4

acid-reign commented 8 years ago

I feel dumb... I forgot to update the CSS file when I updated the javascript file.

Disregard this, and let's never speak of it again.

karamfil commented 8 years ago

Hi

This is still an issue. The main problem is that it is just hidden with css and thus it is quite a performance problem becuase it still needs to render and pass the HTML for the cotrols through jQuery.

If a show* function evaluates to FALSE it should not even be rendered.

And if I want to increase performance I have to actually set the steps

stepMillisec    : 999,
stepMicrosec    : 999,

And just a side note I am not sure if the step should be 1 by default :D

Thanks :)