运行时的JQuery Datepicker

时间:2013-05-08 20:43:37

标签: jquery datepicker runtime

我搜索了网站,但我没有收到线索。我有一个带

的索引页面
    <script type="text/javascript">
            $(document).ready(function($) {


                $('.mnclick').click(function() {     <-------- when a menu is clicked, i load the data picker.
                    var target = $(this).attr("id");

                    $.post("getParam.php",
                            {
                                name: target
                            },
                    function(data, status) {
                        $('p#dataz').empty();
                        $('p#dataz').html(data);
//                        $('p#dataz').append(data);
//                        alert("Data: " + data + "\nStatus: " + status);
                    });
                });

                $( "#datepicker" ).datepicker();
            });
        </script>

但遗憾的是,在运行时加载数据贴纸时,文本框显示但没有显示日期选择器的任何交互。

   <p id="dataz">
                    //this is where the data picker will be displayed
               </p>

我的getparam.php如下:

<?php

$n = $_REQUEST['name'];


$from_to = "<tr>
                <td>Date From:</td>
                <td>        
                    <script type=text/javascript >
                         DateInput('txtFrom', true, 'YYYY-M-DD');
                    </script></td>
            </tr>
            <tr>
                <td>Date To:</td>
                <td>
                    <script type=text/javascript>
                        DateInput('txtTo', true, 'YYYY-M-DD');
                    </script>
                </td>
            </tr>";

if ($n == 'sales_bcbhdhj') {
    sales_grossadd();
}

function sales_grossadd() {
    global $from_to;
    echo "Date: <input type=text class=hasDatepicker  id=datepicker />";
}

?>

请帮我解决问题

1 个答案:

答案 0 :(得分:0)

在帖子回调中移动此$( "#datepicker" ).datepicker();

function(data, status) {
            $('p#dataz').empty();
            $('p#dataz').html(data);
//          $('p#dataz').append(data);
//          alert("Data: " + data + "\nStatus: " + status);
            $( "#datepicker" ).datepicker();
       });