Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in enableOnReadonly option. #55

Closed
noc2spam opened this issue Oct 15, 2015 · 1 comment
Closed

Possible bug in enableOnReadonly option. #55

noc2spam opened this issue Oct 15, 2015 · 1 comment

Comments

@noc2spam
Copy link

My setup (stripped down for easy viewing):

<?php
    echo DatePicker::widget([
        'model' => $model,
        'attribute' => 'visitingDate',
        'type' => DatePicker::TYPE_COMPONENT_APPEND,
        'removeButton' => false,
        'options' => [
                'readonly' => 'readonly',
            'placeholder' => Yii::t('app', 'Enter booking date'), 'class' => 'form-control', 'id' => 'txtBookingFormChangeDoctorDate' , ],
        'pluginOptions' => [
            'enableOnReadonly' => false,
            'autoclose' => true,
            'startDate' => 0,

        ],

    ]);
?>

HTML Output:

<div id="txtBookingFormChangeDoctorDate-kvdate" class="input-group date">
    <input type="text" id="txtBookingFormChangeDoctorDate"
     class="form-control" 
     name="DoctorAppointmentBookings[visitingDate]" 
    readonly="readonly" 
    placeholder="Enter booking date" 
    data-datepicker-source="txtBookingFormChangeDoctorDate-kvdate" 
    data-datepicker-type="3" 
    data-krajee-kvdatepicker="kvDatepicker_52d3049e">
    <span class="input-group-addon kv-date-calendar" title="Select date">
    <i class="glyphicon glyphicon-calendar"></i>
    </span>
</div>

Readonly is set on the input field with txtBookingFormChangeDoctorDate, as you can see. Now, in bootstrap-datepicker.js, on line number 417 - 418, we have:

if (this.element.attr('readonly') && this.o.enableOnReadonly === false)
    return;

If I do console.log(this.element), I get :

    [
    div#txtBookingFormAllocateDate-kvdate.input-group.date, 
    context: div#txtBookingFormAllocateDate-kvdate.input-group.date
    ]

Which means, this.element is the parent div, under which, the readonly input resides. So, essentially, this.element.attr('readonly') will always return undefined, because the parent div does not have any readonly attribute set ( and that's not expected either).

Could anyone look at it? Fix would be simple, but I just want to make sure that the source is also updated.

@noc2spam
Copy link
Author

The following code in bootstrap-datepicker.js ( line 417 - 418) fixes the issue for me.

 if (this.element.find('input.form-control').attr('readonly') && this.o.enableOnReadonly === false)
   return;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants