When I use a datepicker inside a modal the datepicker is not working.
I use the event show.bs.modal to modify some content of the modal on show:
$(function(){
$('#statusModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var title = button.data('title');
var input_date = button.data('date');
var modal = $(this);
modal.find('.modal-title').text('Clicked: ' + title);
modal.find('.modal-body #inputDate').val(input_date);
$('#inputDate').datepicker();
}).on('hidden.bs.modal', function (event) {
$('#inputDate').datepicker('remove');
});
$('#inputDate2').datepicker();
})
But this event gets fired again when the datepicker opens. Because of this, it delets the value of the date input. And selecting a date does also not work.
Here a jsfiddle that demonstrates the problem: http://jsfiddle.net/f9de9z8x/26/
Any idea what's wrong?
Try this,
$("input.date-picker").click(function(){
});
Try using the
shown
event instead of theshow
event.http://jsfiddle.net/kp0q9s9L/