首页 > 解决方案 > 在模态中初始化后日期选择器不显示

问题描述

我有 Javascript 在模式中显示它后 incialize datepicker。当我调试它时,一切看起来都很好,即使我在控制台中触发了初始化,但 datepicker 仍然没有显示出来。

这是我的 JS 代码:

$('<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">' + '<div id="modal-container" class="modal-dialog .modal-dialog-centered" style="height:80% !important;max-width:80%;!important">' +
                '<div class="modal-content" id= "modalbody" >' +
                data + '</div></div></div>').modal();
                            $('input[data-datepicker]').datepicker({
                                format: 'dd.mm.yyyy',
                                days: ['Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek'],
                                daysShort: ['Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'],
                                daysMin: ['Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'],
                                months: ['Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec'],
                                monthsShort: ['Led', 'Úno', 'Bře', 'Dub', 'Kvě', 'Čer', 'Čec', 'Srp', 'Zář', 'Říj', 'Lis', 'Pro'],
                                autoHide: true
                            });

在 data 属性中是模态体,其中包含以下输入:

<input title="@i.Value" style="padding-right:30px; width:100%" autocomplete="off" type="text" data-datepicker required class="disabled" name="@i.Id" id="@i.Id" value="@i.Value" onfocusout="return SaveEdit('@i.Id');" />

有谁知道这是什么原因?

标签: javascripthtmldatepickerrazor-pages

解决方案


推荐阅读