引导程序的Datepicker在模式窗口中不起作用 [英] Datepicker for bootstrap does not work in modal window

查看:74
本文介绍了引导程序的Datepicker在模式窗口中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对引导日期选择器有疑问,我使用插件,因为在过去和依赖的残疾.

I have issue with bootstrap datepicker, I use this plugin, because Disabling dates in the past and dependent disabling.

问题是否可能是因为我在同一页面表单上为Datepicker使用了相同的类两次?您知道为什么会这样吗?

Whether the problem could be because I use twice on the same page form with the same classes for datepicker? Do you have an idea why this is happening?

在这种(第一种)情况下,当我使用此代码(完美工作)

In this (first) situation, when I used this code (work perfect)

<ul class="nav navbar-nav navbar-right">
  <li class="book dropdown">
    <div class="booking btn-default dropdown-toggle btn-block" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="button" title="Book now">Book now</div>
    <div class="dropdown-menu" role="menu">
      <form id="check_available" method="post" action="#" role="form" autocomplete="off">
        <div class="form-group arrival">
          <input type="text" class="form-control date-selector" id="arrival" readonly="readonly" name="arrival" placeholder="ARRIVAL" required>
        </div>
        <div class="form-group departure">
          <input type="text" class="form-control date-selector" id="departure" readonly="readonly" name="departure" placeholder="DEPARTURE" required>
        </div>
        <div class="form-group guests">
          <div class="qty-buttons">
            <input type="button" value="+" class="qtyplus" name="quantity">
            <input type="number" name="quantity" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');" id="quantity" value class="qty form-control required" placeholder="0" required>
            <input type="button" value="-" class="qtyminus" name="quantity">
          </div>
        </div>
        <button type="submit" class="btn-check" id="submit-check" title="Send">Send</button>
      </form>
    </div>
  </li>
</ul>
<!-- /.navbar-right-->

但是在这种情况下,当我在模式窗口中使用相同的表单时(根本不起作用,因为当我单击到达或离开输入时,应该打开打开日期弹出窗口,但是不打开)

but in this case when I used same form in modal windows (does not work at all, because when I click on arrival or departure input, should be opened date popup, but does not)

<div class="modal modal-fullscreen fade" id="book-modal-fullscreen" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">
          <span aria-hidden="true" title="Close">&times;</span>
          <span class="sr-only">Close</span>
        </button>
        <h4 class="modal-title" id="myModalLabel">Book now</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-xs-12 col-sm-12 col-md-12">
            <form id="check_available" method="post" action="#" role="form" autocomplete="off">
              <div class="form-group arrival">
                <input type="text" class="form-control date-selector" id="arrival" readonly="readonly" name="arrival" placeholder="ARRIVAL" required>
              </div>
              <div class="form-group departure">
                <input type="text" class="form-control date-selector" id="departure" readonly="readonly" name="departure" placeholder="DEPARTURE" required>
              </div>
              <div class="form-group guests">
                <div class="qty-buttons">
                  <input type="button" value="+" class="qtyplus" name="quantity">
                  <input type="number" name="quantity" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');" id="quantity" value class="qty form-control required" placeholder="0" required>
                  <input type="button" value="-" class="qtyminus" name="quantity">
                </div>
              </div>
              <button type="submit" class="btn-check" id="submit-check" title="Send">Send</button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

//Datepicker
if (jQuery('#arrival').length) {
  var nowTemp = new Date();
  var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);

  var checkin = $('#arrival').datepicker({
    onRender: function(date) {
      return date.valueOf() < now.valueOf() ? 'disabled' : '';
    }
  }).on('changeDate', function(ev) {
    if (ev.date.valueOf() > checkout.date.valueOf()) {
      var newDate = new Date(ev.date)
      newDate.setDate(newDate.getDate() + 1);
      checkout.setValue(newDate);
    }
    checkin.hide();
    $('#departure')[0].focus();
  }).data('datepicker');
  var checkout = $('#departure').datepicker({
    onRender: function(date) {
      return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
    }
  }).on('changeDate', function(ev) {
    checkout.hide();
  }).data('datepicker');
}

推荐答案

我花了几个小时才能使它生效,但最终我解决了.

I take a few a hour to put this to work but finally I solved.

.bootstrap-datetimepicker-widget {
  z-index:10800 !important;
  display: block;
}

这篇关于引导程序的Datepicker在模式窗口中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆