1

我已经搜索了网站,但我没有收到任何线索。我有一个索引页

    <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 />";
}

?>

请帮帮我,我卡住了

4

1 回答 1

0

将此移动$( "#datepicker" ).datepicker();到您的帖子回调中

function(data, status) {
            $('p#dataz').empty();
            $('p#dataz').html(data);
//          $('p#dataz').append(data);
//          alert("Data: " + data + "\nStatus: " + status);
            $( "#datepicker" ).datepicker();
       });
于 2013-05-08T20:46:02.727 回答