Skip to content

DatePicker Inside Modal Not Working Bootstrap 4 #15

@thatguy76

Description

@thatguy76

I'm using Laravel 5.8 and Bootstrap 4. When using this date picker in a modal, if the month or next / previous buttons are clicked, the calendar just closes. Have you come across this before and know how to fix it? Thanks.

Here is my modal html:

    <div class="modal fade" id="modalTaskForm" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="form-group">
                    <label for="startingDate" class="pb-1">Date</label>
                    <input type='text' class="input-sm form-control" id='startingDate' name="starting_date" value="" />
                </div>
            </div>
        </div>
    </div>

Here is my js:

     $.fn.modal.Constructor.prototype.enforceFocus = function() {};

     $('#modalTaskForm').on('show.bs.modal', function (evt) {
   
          window.myDatePicker = new DatePicker('#startingDate', {
             datePickerClass: 'date-picker ',
             closeOnSelect: false,
          });
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions