Using Bootstrap DatetimePicker with Sweet Alert 2 - Display calendar over alert

10,773

Create an additional class in your style sheet:

.swal2-overflow {
  overflow-x: visible;
  overflow-y: visible;
}

Add this new class to your sweet alert code using the customClass attribute.

swal({
  title: 'Date picker',
  html: '<input id="datepicker">',
  showConfirmButton: false,
  customClass: 'swal2-overflow',
  onOpen: function() {
      $('#datepicker').datetimepicker({});
  },

}).then(function(result) {

});
Share:
10,773
Codewise
Author by

Codewise

Updated on June 11, 2022

Comments

  • Codewise
    Codewise almost 2 years

    I am using the SweetAlert2 dialog with a form inside. I want to use the Bootstrap DateTimePicker widget.

    The calendar widget popup is displayed within the SweetAlert window instead of over top of it. This makes the alert expand and contract - and you must scroll inside the alert to see the calendar. The desired behavior is for the calendar to display as a child of the primary page and display over top of the alert.

    https://jsfiddle.net/ghr2bwoc/13/

      swal({
        title: 'Date picker',
        html: '<input id="datepicker">',
        showConfirmButton: false,
        onOpen: function() {
            $('#datepicker').datetimepicker({});
        },
    
      }).then(function(result) {
    
      });