简体   繁体   English

beforeShowMonth在bootstrap datepicker中不起作用

[英]beforeShowMonth is not working in bootstrap datepicker

I have used bootstrap datepicker in my project which is then tied to the html is as follows 我在我的项目中使用了bootstrap datepicker,然后绑定到html如下

<div id="calendar"></div>

I works fine till here but when I tried to capture event called beforeShowMonth its not working, I mean I have put one console.log statement into it but its not getting printed, because command is not reaching there. 我工作正常,直到这里但是当我试图捕获名为beforeShowMonth事件时它不起作用,我的意思是我已经将一个console.log语句放入其中但它没有被打印,因为命令没有到达那里。 Same way if I try beforeShowDay it works fine. 同样的方式,如果我尝试beforeShowDay它工作正常。 what can be the error, or am I making any non sense mistake while capturing the event. 什么可能是错误,或者我在捕获事件时犯了任何无意义的错误。 angularjs controller code is as follows angularjs控制器代码如下

$('#calendar').datepicker({
            format:"yyyy-mm-dd",
            setDate: new Date(),
            todayHighlight: true,
            beforeShowMonth: function(date){
                console.log("In before Show month: "+date.getMonth());
            },
            beforeShowDay: function(date){
                console.log("In before Show Day");
            }
        });

Any suggestion? 有什么建议吗? If not then can anyone tell me how can I write beforeShowDay after initializing. 如果没有,那么任何人都可以告诉我如何在初始化之后在beforeShowDay之前写。 I have used option to do it this also not working. 我用过option来做这个也行不通。 Please help me 请帮我

The beforeShowMonth and beforeShowDay MUST return some of those options: beforeShowMonth和beforeShowDay必须返回其中一些选项:

  • undefined to have no effect 未定义无效
  • A Boolean, indicating whether or not this date is selectable 一个布尔值,指示此日期是否可选
  • A String representing additional CSS classes to apply to the date's cell 一个String,表示要应用于日期单元格的其他CSS类
  • An object with the following properties 具有以下属性的对象

 beforeShowMonth: function(date){ console.log("In before Show month: "+date.getMonth());3 return ""; }, beforeShowDay: function(date){ console.log("In before Show Day"); return ""; } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM