I am using jQuery Datepicker inside a page, which works when complete page is loaded in browser, but when I load the same page in bootstrap modal pop-up, jQuery datepicker inside it doesn't work.
Not sure how to solve it, here is my textbox HTML
<div class="form-group form-group-default input-group col-md-12">
<div class="form-input-group">
<label class="label-lg fade">Event Date</label>
<input class="form-control input-lg" id="EventDate" name="EventDate" type="text">
</div>
<div class="input-group-addon ">
<i class="fa fa-calendar"></i>
</div>
</div>
And jQuery to initialize it
$("#EventDate").datepicker();
There is no error in Console also, but cannot see datepicker
There can be two possible reasons of datepicker not working inside bootstrap pop-up modal.
$("body").delegate("#DatePicker", "focusin", function () {
$(this).datepicker();
});?
If above code works for you, the reason it's wasn't working for you is because your datepicker is being bound to elements that exist at the time the script is run.
.datepicker{ z-index:99999 !important; }?
one of the above solutions should resolve your issue.
@manish you are genius. your solution worked like a charm. thanks alot.
You can also initialize datepicker once modal is shown, and make main container of datepicker as Modal
$('#yourModal').on('shown.bs.modal', function() {
$('.date').datepicker({
format: "dd/mm/yyyy",
startDate: "01-01-2019",
autoclose: true,
todayHighlight: true,
container: '#YourModalBodyDiv'
});
});
and set Z-Index of datepicker as mentioned above ".datepicker{
z-index:99999
; }
"
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly