ajax 调用后日期选择器不会在文本上显示日期
我有一个 div
id 为 inPatientDecision
,其内容是通过 Ajax 调用动态加载的。加载的内容有一些 HTML datepicker 元素,其类属性设置为 datePicker
。为了将 Jquery UI Datepicker 日历实例化到这些元素,我在 ajax complete
上设置了 $(\'.datePicker\').datePicker();
。 ajax 调用是:
jQuery.ajax({type:'POST',
data:{'inpatientDecisionId': '6'},
url:'/myproje/um/editDecision/13',
success:function(data,textStatus){
jQuery('#inPatientDecision').html(data);},
error:function(XMLHttpRequest,textStatus,errorThrown){},
complete:function(XMLHttpRequest,textStatus){
$(\'.datePicker\').datepicker();
}});;
alt="Edit Authorization Decision" src="/everest/images/edit_icon.png">
现在,当加载内容并单击 datepicker 元素时,我肯定可以显示日历。但是当我选择任何日期时,所选日期不会显示在输入框中。
当然,这里已经问过类似的问题之前,但提供的解决方案对我没有多大帮助(可能对之前的OP也没有多大帮助,答案尚未被接受)。
I have a div
ided as inPatientDecision
, the contents for which are loaded dynamically through an Ajax call. The loaded content has a few HTML datepicker elements with class attribute set to datePicker
. To instantiate the Jquery UI Datepicker calendar to those elements, I've set $(\'.datePicker\').datePicker();
on ajax complete
. The ajax call is:
jQuery.ajax({type:'POST',
data:{'inpatientDecisionId': '6'},
url:'/myproje/um/editDecision/13',
success:function(data,textStatus){
jQuery('#inPatientDecision').html(data);},
error:function(XMLHttpRequest,textStatus,errorThrown){},
complete:function(XMLHttpRequest,textStatus){
$(\'.datePicker\').datepicker();
}});;
alt="Edit Authorization Decision" src="/everest/images/edit_icon.png">
Now when the content loads and the datepicker element is clicked, I sure can get the calendar displayed. But when I select any date, the selected date is not displayed to the input boxes.
Sure something like this has been asked here before but the solutions provided haven't been much helpful to me (possibly neither to the previous OP, an answer hasn't been accepted).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅下面我更新的代码
基本完成和成功将一起执行,所以我只是在将 html 放入成功部分后放置日期选择器。
希望这应该有效。
Please see my updated code below
Basically complete and success would execute together, so i just placed datepicker after you place html in success section.
Hopefully this should work.