I'm using bootstrap-datepicker
and created a function that resets the datepicker date to today, everything works fine except, when I call my function, it automatically opens the calendar box which stays on page and doesn't disappear even when lose focus. How can I avoid this issue, or not open calendar automatically when date reset (I tried some solutions from stack but nothing worked..)
date picker config
$('#sandbox-container .input-group.date').datepicker({
language: "he",
rtl: true,
autoclose: true,
todayHighlight: true,
format: "dd/mm/yyyy"
});
function that resets date
function resetStartDatePicker() {
//option 1 - didn't work
$("#sandbox-container").focusout(function () {
$("#sandbox-container").hide;
});
//option 2 - didn't work
$("#sandbox-container ~ .ui-datepicker").hide();
//option 3 - didn't work
$("#sandbox-container").datepicker().on('changeDate', function () {
$(this).blur();
});
//option 4 - didn't work
$.fn.datepicker.defaults.autoclose = true;
var today = getToday();
$("#sandbox-container").find("input").val(today.a);
$("#sandbox-container").datepicker("update", today.b);
}
HTML
<div id="sandbox-container" >
<div id="positionSorter" style="margin-top:10%">
<a id="anotherDatelink" title="reset" class="pull-left" href="#" onclick="resetStartDatePicker()">reset</a>
</div>
<div class="input-group date" data-provide="datepicker" style="float:right">
<input type="text" class="form-control @semanticClass" name="@Model.Name" id="@Model.Id" title="@Model.Name" value="@val">
<div class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</div>
</div>
</div>