Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide the datepicker on blur event

I am trying to add an event blur on input in order to hide a calendar.
The plugin I am using to show the calendar is the foliowing eternicode/bootstrap-datepicker.

Here is the source code http://jsfiddle.net/KLpq7/75/

var inputs = $('.datepicker').datepicker({
    autoclose: true
});

inputs.on('blur', function () {
          console.log($(this));
          // I would like to hide just the date picker
          //$(this).hide();
});
like image 617
Lorraine Bernard Avatar asked Oct 02 '12 13:10

Lorraine Bernard


2 Answers

You can try this:

var inputs = $('.datepicker').datepicker({
format: 'yyyy-mm-dd',
autoclose: true}).on('changeDate', function (ev) {
         $(this).blur();
         $(this).datepicker('hide');
     });

Fiddle: http://jsfiddle.net/KLpq7/82/

like image 161
Irvin Dominin Avatar answered Sep 27 '22 17:09

Irvin Dominin


    inputs.on('blur', function () {
        inputs.datepicker('hide');
    });
like image 44
antonjs Avatar answered Sep 27 '22 16:09

antonjs