Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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) {

  });
like image 688
Codewise Avatar asked Aug 22 '17 19:08

Codewise


1 Answers

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) {

});
like image 180
taekwondoalex Avatar answered Nov 08 '22 19:11

taekwondoalex