简体   繁体   中英

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

<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. Same way if I try beforeShowDay it works fine. what can be the error, or am I making any non sense mistake while capturing the event. angularjs controller code is as follows

$('#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. I have used option to do it this also not working. Please help me

The beforeShowMonth and beforeShowDay MUST return some of those options:

  • 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
  • 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 ""; } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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