Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Onclick day close bootstrap datepicker

I want to close datepicker when click on day. How is this possible in Bootstrap Datepicker?

Here is the fiddle:

http://jsfiddle.net/kGGCZ/17/

$('#dob').datepicker(
{
    endDate:ageDate
}
);
like image 252
Hassan Sardar Avatar asked Feb 20 '14 05:02

Hassan Sardar


3 Answers

You the auto-close property of the bootstrap date-piker like below

$('#dob').datepicker(
{
    endDate:ageDate,
    autoclose: true
}
);

I have already updated your js-fiddle

Updated fiddle

like image 67
Bharat soni Avatar answered Nov 12 '22 19:11

Bharat soni


Note that if you are using Stefan Petre's original version of the Bootstrap Datepicker, the autoclose property will [as of this writing] not work. In this case, you should do something like this:

$('#myDate').datepicker().on('changeDate', function (e) {
    $('#myDate').datepicker('hide');
});

If you're using eternicode's forked version, the autoclose property will work.

like image 6
contactmatt Avatar answered Nov 12 '22 20:11

contactmatt


initialize your date picker with option 'autoclose'

$('#dob').datepicker(
{"autoclose": true});

or you can close date picker by using following code also

$('#dob').datepicker().on('changeDate', function (ev) {
    $('#dob').hide();
    });
like image 4
chriz Avatar answered Nov 12 '22 20:11

chriz