tempusdominus / bootstrap-4

Tempus Dominus Bootstrap 4 Datetime Picker
https://getdatepicker.com/5-4/
MIT License
611 stars 239 forks source link

ignoreReadonly not working properly #362

Open samozeleznik opened 3 years ago

samozeleznik commented 3 years ago

I want to disable keyboard popping up on mobile when opening the datetimepicker.

The first issue is that initializing the datepicker overrides the readonly attribute of the input field. That means you have to set it after initializing datetimepicker (example of the issue: https://jsfiddle.net/q85tcf60/3/)

I was able to get around this with the following code:

    $('#datetimepicker1').datetimepicker({
      ignoreReadonly: true
    });
    $('#datetimepicker-input-1').attr("readonly", "readonly");

HTML:

    <div class="input-group date mb-1 w-auto" id="datetimepicker1" data-target-input="nearest">
      <input type="text" id="datetimepicker-input-1" class="form-control datetimepicker-input" data-target="#datetimepicker1" data-toggle="datetimepicker" />
      <div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
          <div class="input-group-text"><i class="fa fa-calendar"></i></div>
      </div>
    </div>

The issue is, that this way you cannot select a new value for the field. The datetimepicker opens up, but nothing is clickable and you cannot select a different time or date.

JsFiddle example: https://jsfiddle.net/q85tcf60/2/

EDIT: Tested this functionality with datetimepicker 4.15.35 and it seems to be working fine.

ya2nk commented 3 years ago

just uncomment unminified js code in line 2253

if (this.input !== undefined && this.input.prop('readonly') || this._options.readonly) { //template.addClass('bootstrap-datetimepicker-widget-readonly'); }