在新的窗口jquery功能不工作

In new window jquery functions not working

本文关键字:功能 工作 jquery 窗口      更新时间:2023-09-26

我有这个代码在我的项目中打开一个新窗口来显示,然后,从我的第一个窗口写内容。之后,我用一些页面替换了某个div,但是在这个窗口javascript函数不起作用。如何在新生成的寡妇启用javascript功能?这是我的窗口生成jquery脚本

$('.ledger_edit').on('click', function (e) {
        e.preventDefault();
        var mywindow = window.open(window.location.href);
        $(mywindow.document).ready(function () {
            $.ajax({
            url: $(this).attr('href'),
                success: function (data)
                {
                    $(mywindow.document).contents().find("div.content").html(data);
                    mywindow.onload = function () {
                        alert()
                        mywindow.contents().find(".ledger").select2();
                        calculateTotal();
                    }
                }
            });
        });
    })

我的新窗口内容div替换为以下HTML代码

    <form method="post" action="#">
                <input type="hidden" id="PID" name="PID" value="">
          <input type="hidden" id="action" name="action" value="update_project">
 ...
        <input type="button" id="proj_submit" class="ui blue submit button right floated" value="Update">
            </form></div>
<script>
$(document).ready(function() {
 $( "form" ).on( "submit", function(e) {
     e.preventDefault();
    data = $(this).serialize();
     $.ajax({
        type:"POST",
        url: "functions_new.php",
        data:data,
        success: function() {
            alert("Updated");
        }
});
});
});
$new_date =  date('Y-m-d', strtotime($date));

尝试使用strtotime()函数,

$new_date = date('Y-m-d', strtotime($date));