Php 在使用ajax响应刷新数据后,如何使用html元素绑定jquery对话框?

Php 在使用ajax响应刷新数据后,如何使用html元素绑定jquery对话框?,php,ajax,jquery-ui,jquery,Php,Ajax,Jquery Ui,Jquery,在我的php页面中,我得到了一个jquery脚本来打开一个对话框窗口。代码如下所示 <script type="text/javascript"> $(document).ready(function() { var $loading = $('<img src="loading.gif" alt="loading" class="loading">'); $('#data-spec

在我的php页面中,我得到了一个jquery脚本来打开一个对话框窗口。代码如下所示

<script type="text/javascript">
            $(document).ready(function() {
                var $loading = $('<img src="loading.gif" alt="loading" class="loading">');

                $('#data-specs a').each(function() {
                    var $dialog = $('<div></div>')
                        .append($loading.clone());

                    var $link = $(this).one('click', function() {
                        $dialog

                            .load($link.attr('href'))
                            .dialog({
                                title: '<?php echo $_GET["indQ"];?>',
                                modal: true,
                                width: 500,
                                height: 300,
                                minHeight: 300,
                                maxHeight: 600,
                                minWidth: 500,
                                maxWidth: 800
                                });

                            $link.click(function() {
                            $dialog.dialog('open');

                            return false;
                        });

                        return false;
                    });
                });

                $('#dav').val(getURLParameter('davQ'));

                $('#pathogen').val(getURLParameter('pathogenQ'));

                $('#topicF').val(getURLParameter('topicQ'));

                $('#ind').val(getURLParameter('indQ'));

                $('#subind').val(getURLParameter('subindQ'));

                $(".selfont").change(function (event) {
                        window.location = '?davQ=' + $('#dav').val() + '&pathogenQ=' + $('#pathogen').val() + '&topicQ=' + $('#topicF').val() + '&indQ=' + encodeURIComponent($('#ind').val()) + '&subindQ=' + encodeURIComponent($('#subind').val());
                });

                function getURLParameter(name) {
                         return decodeURIComponent((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1]);
                }

            });
    </script>

$(文档).ready(函数(){
变量$loading=$('');
$(“#数据规格a”)。每个(函数(){
变量$dialog=$('')
.append($loading.clone());
var$link=$(this).one('click',function(){
$dialog
.load($link.attr('href'))
.对话({
标题:“”,
莫代尔:是的,
宽度:500,
身高:300,
身高:300,
最大高度:600,
最小宽度:500,
最大宽度:800
});
$link.click(函数(){
$dialog.dialog('open');
返回false;
});
返回false;
});
});
$('#dav').val(getURLParameter('davQ'));
$('#病原体').val(getURLParameter('athorgaq');
$('#topicF').val(getURLParameter('topicQ'));
$('#ind').val(getURLParameter('indQ'));
$('#subind').val(getURLParameter('subindQ'));
$(“.selfont”).change(函数(事件){
window.location='?davQ='+$('.#dav').val()+'&aghorq='+$('.#病原体').val()+'&topicQ='+$('.#topicF').val()+'+indQ='+encodeURIComponent($('.#ind').val())+'&subindQ='+encodeURIComponent($($('.#subind subind').val())));
});
函数getURLParameter(名称){
返回decodeURIComponent((RegExp(name+'='+'(.+?)(&|$)).exec(location.search)| |[,null])[1]);
}
});
数据位于id='data-specs'的表中。而且效果很好。最近,我添加了一个带有值的下拉框,使用ajax脚本对该表进行排序,它也可以工作。但问题是在这个ajax调用之后,当我单击链接打开对话框窗口时,它会在父窗口中打开,如果我们按下浏览器后退按钮,然后单击链接,它将打开对话框窗口,不会出现错误!!即使在使用ajax完成排序之后,我如何使其正确?请给我一些解决办法。我要排序的ajax代码如下所示

function ajaxFunction(){

    //to keep selection in countryList - GP
    var ref = document.getElementById('countryRF');
    for(i=0; i<ref.options.length; i++)
    ref.options[i].selected = true;


    var ajaxRequest;  // The variable that makes Ajax possible!

    try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        // Internet Explorer Browsers
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
            //document.myForm.time.value = ajaxRequest.responseText;
            document.getElementById("result").innerHTML=ajaxRequest.responseText

        }
    }

    var dav = document.getElementById('dav').value;
    var pathogen = document.getElementById('pathogen').value;
    var topicF = document.getElementById('topicF').value;
    var ind = document.getElementById('ind').value;
    var subind = document.getElementById('subind').value;
    var selObj = document.getElementById('countryRF');
    var cnty = loopSelected(selObj).join('~');  // join array into a string
    var sortby = document.getElementById('sortby').value;

    var queryString = "?dav=" + dav + "&pathogen=" + pathogen + "&topicF=" + topicF + "&ind=" + encodeURIComponent(ind) + "&subind=" + encodeURIComponent(subind) + "&cnty=" + encodeURIComponent(cnty) + "&sortby=" + sortby;
    ajaxRequest.open("GET", "sortbyD.php" + queryString, true);
    ajaxRequest.send(null);
    return false;
}
函数ajaxFunction(){
//在countryList-GP中保留所选内容
var ref=document.getElementById('countryRF');

对于(i=0;i当第一次加载页面时,对话框事件与元素绑定,在ajax之后,您需要再次将对话框事件与.bind()绑定)函数

感谢您的回复,您能告诉我怎么做吗?我会尝试一下,并告诉您结果。是否有可能获得有关此的任何线索?很抱歉,我没有做到这一点?这就是为什么我要求提供任何链接或资源来做这件事。或者您能给我一个开始吗?在ajax响应后编写$('#foo')。绑定(“单击”,您的函数在此处登录);