0

I'm trying to hide inline datepicker when click somewhere else than datepicker, but it also disappears when click on nextMontButton and previousMonthButton

Any idea?

<div id="all">
 <div id="datepicker"> </div> //here is datpicker
 <div id="submitDiv"> //here is submit in datepicker style
     <input type="submit" name="day" value="Done" id="datePickerSubmit"> 
     <input type="hidden" id="date" name="date" value="">
 </div> 
</div>

jQuery(document).ready(function(){
jQuery('#datepicker').datepicker({
      firstDay: 1,
      minDate: +2,
      maxDate: "+1m",
      dateFormat: "yy-mm-dd",
      inline: true,
      altField: '#date'
    });
})


// HIDES DATETIME PICKER WHEN CKICK SOMEWHERE ELSE
$(document).click(function(e) {
    var target = e.target;

    if (!$(target).is('#all') && !$(target).parents().is('#all'))) {
       document.querySelector("#datepicker").style.display = "none";
       document.querySelector("#submitDiv").style.display = "none";
    }
});
gr3g
  • 2,866
  • 5
  • 28
  • 52
  • normally the datapicker hide himself when he lost the focus. You don't have to do this manually. – Mathieu Labrie Parent Oct 20 '14 at 20:09
  • 1
    @MathieuLabrieParent That's true when the datepicker appears on demand when you click on an input. It's not the default for inline datepickers. – Barmar Oct 20 '14 at 20:16
  • 1
    I've created a fiddle based on @Barmar's reference: http://jsfiddle.net/zpc3jLhd/3/ Note that even though `datepicker` is inline, it still takes up the entire width, as you'll see with the yellow background I gave it. – Rick Hitchcock Oct 20 '14 at 20:32

0 Answers0