Bootstrap Datepicker未在模式中唤醒 [英] Bootstrap datepicker not woking in modal
本文介绍了Bootstrap Datepicker未在模式中唤醒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在模式内部使用datepicker时,datepicker无法正常工作.
When I use a datepicker inside a modal the datepicker is not working.
我使用事件show.bs.modal来修改show上模态的某些内容:
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.
这里有一个展示问题的jsfiddle: http://jsfiddle.net/f9de9z8x/26/
Here a jsfiddle that demonstrates the problem: http://jsfiddle.net/f9de9z8x/26/
你知道怎么了吗?
推荐答案
尝试使用shown
事件而不是show
事件.
Try using the shown
event instead of the show
event.
$('#statusModal').on('shown.bs.modal', function (event) {
这篇关于Bootstrap Datepicker未在模式中唤醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文