Hassan Sardar
Hassan Sardar

Reputation: 4523

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
}
);

Upvotes: 11

Views: 22282

Answers (4)

dfortun
dfortun

Reputation: 764

$('#Date3').datepicker({
        format: "mm-yyyy",
        viewMode: "months",
        minViewMode: "months"
    }).on('changeDate', function (e) {
        $('#Date3').datepicker('hide');
    });

Upvotes: 0

contactmatt
contactmatt

Reputation: 18610

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.

Upvotes: 6

chriz
chriz

Reputation: 1345

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();
    });

Upvotes: 4

Bharat soni
Bharat soni

Reputation: 2786

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

Upvotes: 34

Related Questions