tempusdominus / bootstrap-4

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

readonly option not documented ignoreReadonly not working #390

Open inuryuutarou opened 8 months ago

inuryuutarou commented 8 months ago

I have problem with ignoreReadonly that each time i set my input as readonly it would always remove those attribute somehow.. so I do some debug and find that there is this readonly option in line 1109

this._options.readonly = _readonly;

      if (this.input !== undefined) {
        this.input.prop('readonly', this._options.readonly);
      }

So I add the readonly:true, but this give some other problem as the dates is not clickable at all.. even when i already use ignoreReadonly:true and again I check the code and find this in line 2253

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

so this two option is somehow not supporting each other.. I change the condition to

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

And it work as how I intended it to be.. may this post able to help anyone that experience same issue as me..

and in the minified JS if you want, you could change this part from

(void 0!==this.input&&this.input.prop("readonly")||this._options.readonly)

into

(void (0!==this.input&&this.input.prop("readonly")||this._options.readonly)&&this._options.ignoreReadonly==false)

just use find to search the code and replace it.