解决方案 »

  1.   

    $(function () {
        $("input[xtype='date']").datepicker();
        $("input[xtype='date']").datepicker({ dateFormat: "yy/mm/dd", changeMonth: true, changeYear: true });
        $("input[xtype='date']").datepicker("option", $.datepicker.regional["zh-CN"]);
        //上面的代码有运行,可以显示日期选择控件
        $("#childAdd").click(function () {
            //动态添加一些控件,其中有一个【$("input[xtype='date']")】的控件
            //改成这样试试,只给最新添加进去的input设置datepicker
            var newAdd = $(ChildInfo).appendTo("#ChildTable");
            newAdd.find("input[xtype='date']").click(function () {
                alert("点我");//此句有运行,跳出窗口
                //以下代码不知道到底想干嘛,已经是datepicker了,还要在click的时候再绑定datepicker?
                // $(this).datepicker();//没反应
                // $(this).datepicker({ dateFormat: "yy/mm/dd", changeMonth: true, changeYear: true });//没反应
                // $(this).datepicker("option", $.datepicker.regional["zh-CN"]);//没反应
            });
            newAdd.find("input[xtype='date']").datepicker();//没反应
            newAdd.find("input[xtype='date']").datepicker({ dateFormat: "yy/mm/dd", changeMonth: true, changeYear: true });//没反应
            newAdd.find("input[xtype='date']").datepicker("option", $.datepicker.regional["zh-CN"]);//没反应
        });
    });改成这样试试。
      

  2.   

    回复2楼,一样的,就alert有运行,其他的没有运行
    应该是 datepickeer 什么地方有问题吧!?
      

  3.   


    代码没什么问题,建议你把alert去掉,换成console.log或者直接不要加这行。
    毕竟alert会阻止JS代码运行的。
      

  4.   

    回3楼,去掉alert一样不行,本来就是没有alert的,为了调试是否有运行,才加进去alert的
      

  5.   

    有没有办法用 live 或者 on 整一下?
      

  6.   

    你要是想动态生成,应该每次都生成标签,然后再使用datepicker,最后附加到相应的元素上显示出来。
    比如这样——
    <button id="btn">add</button>
     <script>
            $("#btn").click(function () {
                $("<div></div>").datepicker().appendTo("body");
            });
     </script>
    看样子你的写法是input上创建datepicker,接着附加元素,这样就有的元素已经有datepicker而有的没有。
    你又不加以区别,通通选中,全都绑定click事件,全都使用datepicker。
    ……总的来说你写的太混乱了……
      

  7.   


        $("input[xtype='date']").live("focus", function () {
        $(this).datepicker({ dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true });
        });