-3

如何在动态加载的 textbox.ie 中添加 Jquery datepicker,当我单击按钮时,包含来自外部页面的文本框的弹出窗口将显示在当前页面中。在那个文本框中我想使用 datepicker。

我使用以下 ajax 加载外部页面

    <script type="text/javascript">
function manageapp(id,apcno)
    {
        /*alert(id);
        alert(apcno);*/
        //alert(dd);
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            req=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            req=new ActiveXObject("Microsoft.XMLHTTP");
        }
        var strURL="manage_ajx.php?id="+id+"&acpno="+apcno;
        if (req) 
        {
            req.onreadystatechange = function() {
            if (req.readyState == 4) {
             // only if "OK"
                if (req.status == 200) 
                {
                    document.getElementById('show_details').innerHTML=req.responseText;
                } else {
                    alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }               
            }           
            req.open("GET", strURL, true);
            req.send(null);
        }   
    }


 </script>

跟随弹出

 <script type="text/javascript">
//New Pop up
$(document).ready(function() {
    $('#inline').hide();
    $('.login-window').click(function() {

            $('#inline').addClass("login-popup");
            $('#inline').css({'visibility':'visible'});

        // Getting the variable's value from a link 
        var loginBox = $(this).attr('href');

        //Fade in the Popup and add close button
        $('#inline').fadeIn(300);

        //Set the center alignment padding + border
        var popMargTop = ($(loginBox).height() + 24) / 2; 
        var popMargLeft = ($(loginBox).width() + 24) / 2; 

        $('#loginBox').css({ 
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
        });

        // Add the mask to body
        $('body').append('<div id="mask"></div>');
        $('#mask').fadeIn(300);

        return false;
    });

    // When clicking on the button close or the mask layer the popup closed
    $('a.close, #mask').live('click', function() { 
      $('#mask , .login-popup').fadeOut(300 , function() {
        $('#mask').remove();  
    }); 
    return false;
    });
});
</script>

以下是调用thae弹出页面//php编码

<a class="login-window" href="#inline"  title="Business Details" onclick="javascript:manageapp('<?php echo $patientlist[$i]['ap_id']; ?>','<?php echo $patientlist[$i]['apc'];?>')">

<img src="images/calendar-icon.png" title="manage appointment"/>

</a> 

?> //php 编码

任何机构都可以帮助我解决这个问题

4

3 回答 3

1
<!doctype html>

<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery UI Datepicker - Default functionality</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
   <link rel="stylesheet" href="/resources/demos/style.css" />
    <script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
    </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker" /></p>


</body> 
</html>

更多详情请点击链接http://jqueryui.com/datepicker/

于 2012-12-27T07:22:21.967 回答
0

试试这个:

$(document).on('load', 'your_datepicker_class_or_id', function(){
   $(this).datepicker();
});

并假设you have these to referenced在你的js东西之上:

<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
于 2012-12-27T07:37:01.080 回答
0

我找到了解决方案,按如下操作,在Ajax返回函数中添加datepicker函数即成功

<script type="text/javascript">
    function manageapp(id,apcno)
    {
        /*alert(id);
        alert(apcno);*/
        //alert(dd);
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            req=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            req=new ActiveXObject("Microsoft.XMLHTTP");
        }
        var strURL="manage_ajx.php?id="+id+"&acpno="+apcno;
        if (req) 
        {
            req.onreadystatechange = function() {
            if (req.readyState == 4) {
             // only if "OK"
                if (req.status == 200) 
                { 


                    document.getElementById('show_details').innerHTML=req.responseText;


                        $("#frompop").datepicker({
                            defaultDate: "+1w",
                            changeMonth: true,
                            changeYear: true,
                            numberOfMonths: 1,

                        });
                        $('#timepickerpop').timepicker({ 'timeFormat': 'g:i A','step':15,'minTime': '8:00am','maxTime': '8:00pm'  });



                } else {
                    alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }               
            }           
            req.open("GET", strURL, true);
            req.send(null);
        }   
    }
    </script>
于 2012-12-28T04:24:10.703 回答