Bootstrap datetimepicker自动关闭不起作用

时间:2017-07-25 08:44:36

标签: twitter-bootstrap bootstrap-datetimepicker

我创建了两个datetimepickers。一切正常,只有autoclose不起作用(从日历中选择日期后)。

Autoclose是datetimepickers上的设置之一:

$('#dateFrom').datetimepicker({
    format: 'dd.mm.yyyy',
    minView: 2,
    maxView: 4,    
    autclose: true
  });

$('#dateTo').datetimepicker({
    format: 'dd.mm.yyyy',
    minView: 2,
    maxView: 4,    
    autclose: true
  });

为什么它不起作用?

示例是here

1 个答案:

答案 0 :(得分:2)

应该有'autoclose'而不是'autclose'。

$('document').ready(function() {

  var curIndex = 0;
  var src = ['http://www.jqueryscript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg', 'http://www.jqueryscript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg', 'http://www.jqueryscript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg'];
  var fadeTimeInMilliseconds = 2000;
  var waitTimeInMilliseconds = 5000;

  $(document).ready(function() {
    switchImageAndWait(true);
  });

  function switchImageAndWait(fadeOut2) {
    if (fadeOut2) {
      setTimeout(fadeOut, waitTimeInMilliseconds);
    } else {
      var index = Math.floor((Math.random() * src.length))
      if (curIndex == index) {
        index++;
        if (index >= src.length) {
          index -= 8;
        }
      }
      curIndex = index;
      $(".client-logo img").attr("src", src[index]);
      fadeIn();
    }
  }

  function fadeOut() {
    $(".client-logo img").fadeTo(fadeTimeInMilliseconds, 0, function() {
      switchImageAndWait(false);
    });
  }

  function fadeIn() {
    $(".client-logo img").fadeTo(fadeTimeInMilliseconds, 1, function() {
      switchImageAndWait(true);
    });
  }

});