balbarak / bootstrap-hijri-datepicker

Bootstrap Hijri Date picker
MIT License
56 stars 53 forks source link

can we have auto close option #22

Closed M-Shalabi closed 2 years ago

M-Shalabi commented 3 years ago

can we have auto close option

autoclose:true

so when losing focus or clicking outside the window it closes

DrAljuhani commented 3 years ago

I'm not a programmer and I think there are better ways but this is how I done it

$(document).mouseup(function(e){ var widget = $(".bootstrap-datetimepicker-widget"); var dateinput = $(".hijri-date-input"); if (!widget.is(e.target) && widget.has(e.target).length === 0 && !dateinput.is(e.target) && dateinput.has(e.target).length === 0){ $('[data-action="close"]').trigger('click'); } });