Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery datepicker()赢得';不处理动态生成的字段_Jquery_Jquery Ui - Fatal编程技术网

Jquery datepicker()赢得';不处理动态生成的字段

Jquery datepicker()赢得';不处理动态生成的字段,jquery,jquery-ui,Jquery,Jquery Ui,下面的第一个脚本在单击时将简单文本(本例中为日期)转换为可编辑字段。然后,我希望在单击动态生成的字段时弹出datepicker()日历,但我无法让日历显示给所有人 <script type="text/javascript"> $(document).ready(function() { var alreadyActive = ""; $(".editable-date").on("click", function() {

下面的第一个脚本在单击时将简单文本(本例中为日期)转换为可编辑字段。然后,我希望在单击动态生成的字段时弹出datepicker()日历,但我无法让日历显示给所有人

<script type="text/javascript">
    $(document).ready(function() {
        var alreadyActive = "";
        $(".editable-date").on("click", function() {
            if(!alreadyActive) {
                OriginalText = $(this).text();
                divValue = $(this).attr('value');
                $(this).html("<form class='edit-date' ><input type='text' class='date_input' value='" + OriginalText + "' /><input type='submit' value='Update' /></form>");
                alreadyActive = "true";
            }
        });
    });
</script>
<script type="text/javascript">
    $(function() {
        $(".date_input").datepicker();
    });
</script>

$(文档).ready(函数(){
var alreadyActive=“”;
$(“.editable date”)。在(“单击”,函数(){
如果(!ALREADYAACTIVE){
OriginalText=$(this.text();
divValue=$(this.attr('value');
$(this.html(“”);
alreadyActive=“true”;
}
});
});
$(函数(){
$(“.date_输入”).datepicker();
});
我还尝试了下面的脚本来调用datepicker(),但没有成功

<script type="text/javascript">
    $(function(){
        $("body").on("click", ".date_input", function() {
            $(this).datepicker();
        });
    });
</script>

$(函数(){
$(“正文”)。在(“单击“,”.date\u输入”,函数()上{
$(this.datepicker();
});
});

您的第二次尝试接近成功,应该是:

$(this).datepicker().triggerHandler("focus");

你的第二次尝试很接近,应该是:

$(this).datepicker().triggerHandler("focus");

我相信你已经这么做了,但以防万一。。。您是否在脚本中的某个地方引用了jQuery和jQueryUI库?我肯定您已经这样做了,但以防万一。。。您是否在脚本中的某个地方引用了jQuery和jQueryUI库?Wunderbar!我犹豫了一下,因为我不知道怎么做,但我很高兴我发现有人知道了怎么做!神童吧!我犹豫了一下,因为我不知道怎么做,但我很高兴我发现有人知道了怎么做!