jQueryUIのDatepickerをBootstrapのmodal上に表示する


こちらの記事の改良版です。

BootstrapのモーダルでjQueryUIのDatepickerのz-index問題を解消する小技 - Qiita

環境

  • jQuery UI 1.12

コード

$.datepicker.setDefaults({
  // options ...
  beforeShow: function() {
    if ($(this).parents('.modal').length) {
      $(this).css('z-index', String(parseInt($(this).parents('.modal').css('z-index') | 0, 10) + 1))
    }
  }
});