ajax 调用后日期选择器不会在文本上显示日期

发布于 2024-12-28 15:43:34 字数 1062 浏览 4 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪我闹别瞎闹 2025-01-04 15:43:34

请参阅下面我更新的代码

jQuery.ajax({type:'POST',
         data:{'inpatientDecisionId': '6'},   
         url:'/myproje/um/editDecision/13',
         success:function(data,textStatus){

         jQuery('#inPatientDecision').html(data);
         $(\'.datePicker\').datepicker();

         },
         error:function(XMLHttpRequest,textStatus,errorThrown){},
});;

基本完成和成功将一起执行,所以我只是在将 html 放入成功部分后放置日期选择器。

希望这应该有效。

Please see my updated code below

jQuery.ajax({type:'POST',
         data:{'inpatientDecisionId': '6'},   
         url:'/myproje/um/editDecision/13',
         success:function(data,textStatus){

         jQuery('#inPatientDecision').html(data);
         $(\'.datePicker\').datepicker();

         },
         error:function(XMLHttpRequest,textStatus,errorThrown){},
});;

Basically complete and success would execute together, so i just placed datepicker after you place html in success section.

Hopefully this should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文