我正在使用Modal Popup点击从Ajax调用FORM,我的问题是,datepicker不能用于模态弹出+ Ajax FORM
这是代码
HTML:
<a href="#" data-toggle="modal" data-target="#myId" class="pickUpClass">Add</a>
<div class="modal fade" id="myId" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal form-bordered" method="post" id="Form2">
<div class="modal-body">
<div class="panel-body panel-body-nopadding cancelForm" style="max-height:400px; overflow:auto;">
</div>
</form>
</div>
</div>
用于调用FORM的AJAX代码
$('a.pickUpClass').click(function(){
$.ajax({
type: "POST",
url: "AJAX.php", //
success: function(msg){
$(".Form2").html(msg);
},
error: function(){
//alert("failure");
}
});
});
AJAX.PHP
<input type="text" class="form-control" name="pickUpDate" id="pickUpDate" required>
当我直接调用AJAX.php时,datepicker工作正常并且通过ajax函数调用datepicker是行不通的。
我能做什么.. ??
答案 0 :(得分:1)
如果您想添加新的bootstrap-datepicker
,则必须通过调用.datepicker()
来初始化应该是日期选择器的输入。
将您的ajax回调函数更改为:
success: function(msg){
$(".Form2").html(msg);
$('#pickUpDate').datepicker({
//options object
});
}, ...