Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript bootstrap-datepicker.js自动关闭且不大于本月_Javascript_Twitter Bootstrap - Fatal编程技术网

Javascript bootstrap-datepicker.js自动关闭且不大于本月

Javascript bootstrap-datepicker.js自动关闭且不大于本月,javascript,twitter-bootstrap,Javascript,Twitter Bootstrap,在我的表单中,我将其与Twitter引导一起用作日期选择器,我很难将其自动关闭,并且任何大于当前月/年的月/年组合都是可选择的。我看了一遍又一遍的文档,但看不到它。感谢您的帮助 我的表格在下面 <div class="control-group"> <label class="control-label" for="CC_CARDEXPIRY"><strong>Card Expiry Month/Year</strong></label

在我的表单中,我将其与Twitter引导一起用作日期选择器,我很难将其自动关闭,并且任何大于当前月/年的月/年组合都是可选择的。我看了一遍又一遍的文档,但看不到它。感谢您的帮助

我的表格在下面

<div class="control-group">
   <label class="control-label" for="CC_CARDEXPIRY"><strong>Card Expiry Month/Year</strong></label>
   <div class="controls">
      <div class="input-append date datepicker" id="CC_CARDEXPIRY" data-date="01/2014" data-date-format="mm/yyyy" data-date-viewmode="years" data-date-minviewmode="months">
         <input class="span6" name="CC_CARDEXPIRY" size="20" type="text" value="01/2015" readonly>
         <span class="add-on"><i class="icon-calendar"></i></span>
      </div>   
   </div>
</div> 

卡到期月/年
我的Javascript目前是

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"</script>    
<script src="../js/bootstrap-datepicker.js"></script>
<script type="text/javascript">  
  $('#CC_CARDEXPIRY').datepicker();              
</script>


默认情况下,“自动关闭”为false。您必须在代码中将其手动设置为一个选项


在玩了datepicker之后,我找到了一种不用触摸自动关闭的方法:

我将此函数置于对日期选择器的调用之上:

var popup =  function(){
    var d = $(this);
    d.datepicker('update', new Date.today().toString("MM/dd/yyyy"))
    .on('changeDate', function(ev){
        // do what you want here
        d.datepicker('hide');
    });
};
然后我对日期选择器的调用如下所示:

this.$('i.icon-calendar').datepicker().on('show', popup);

我强烈建议使用找到的代码,而不是eycon版本。它最初来自eycon,但eternicode维护的github repo拥有更多的追随者,这意味着如果您发现并报告一个bug,它被修复的可能性更大。我并不是说它更容易使用,但有更多的支持。

Hmm我已经查看了上的文档,没有看到如何设置它的示例,你的意思是我需要破解bootstrap-datepicker.js吗?嘿@LJT,我修改了我的答案,现在它包含了一种破解方法,可以让它关闭,而且还有一个不同的来源。