Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用加载已包含jQuery代码(自动完成)内容的表单页的jQuery模式对话框?_Javascript_Jquery_Jquery Ui - Fatal编程技术网

Javascript 使用加载已包含jQuery代码(自动完成)内容的表单页的jQuery模式对话框?

Javascript 使用加载已包含jQuery代码(自动完成)内容的表单页的jQuery模式对话框?,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,我在动态生成的网页中有一个表单,我希望使用jQueryUI模式对话框显示它 我在前一篇文章中提出的解决方案在我的表单未嵌入jQuery UI时有效: 远程表单已经包含jQuery函数的方式是:自动完成 如何解决这个问题 <body> <div> <table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> <t

我在动态生成的网页中有一个表单,我希望使用jQueryUI模式对话框显示它

我在前一篇文章中提出的解决方案在我的表单未嵌入jQuery UI时有效:

远程表单已经包含jQuery函数的方式是:自动完成

如何解决这个问题

<body>
    <div>
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
            <thead>
                <tr>
                    <th>software </th>
                    <th>script</th>
                    <th>exec_type</th>
                    <th>run_status</th>
                    <th>test_result</th>
                    <th>review_status</th>
                    <th>priority</th>
                    <th>author</th>
                    <th>creation date</th>
                    <th>update date</th>
                    <th>edit</th>
                </tr>
            </thead>

            <tfoot>
                <tr>
                    <th>software </th>
                    <th>script</th>
                    <th>exec_type</th>
                    <th>run_status</th>
                    <th>test_result</th>
                    <th>review_status</th>
                    <th>priority</th>
                    <th>author</th>
                    <th>creation date</th>
                    <th>update date</th>
                    <th>edit</th>
                </tr>
            </tfoot>

            <tbody>

            </tbody>



        </table>

    </div>


    <script type="text/javascript" charset="utf-8">

        $('td').click( function(){$("#formContainer").load("myform.html", function() {
                var container = $(this);
                container.dialog({
                    modal: true
                })
                .find("form").submit(function() {
                    container.dialog("close");
                    return false;
                });
            });

        })
        ;
    </script>



</body>

软件
剧本
执行类型
运行状态
测试结果
审查联合国的状况
优先
作者
创建日期
更新日期
编辑
软件
剧本
执行类型
运行状态
测试结果
审查联合国的状况
优先
作者
创建日期
更新日期
编辑
$('td')。单击(function(){$(“#formContainer”).load(“myform.html”,function()){
var容器=$(此);
容器对话框({
莫代尔:对
})
.find(“表单”).submit(函数(){
容器对话框(“关闭”);
返回false;
});
});
})
;
form.html看起来是这样的:

    <script type="text/javascript" charset="utf-8">

        (function($) {
            $.widget("ui.combobox", {
                _create: function() {
                    var self = this;
                    var select = this.element.hide();
                    var input = $("<input>")
                    .insertAfter(select)
                    .autocomplete({
                        source: function(request, response) {
                            var matcher = new RegExp(request.term, "i");
                            response(select.children("option").map(function() {
                                var text = $(this).text();
                                if (this.value && (!request.term || matcher.test(text)))
                                    return {
                                        id: this.value,
                                        label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
                                        value: text
                                    };
                            }));
                        },
                        delay: 0,
                        change: function(event, ui) {
                            if (!ui.item) {
                                // remove invalid value, as it didn't match anything
                                $(this).val("");
                                return false;
                            }
                            select.val(ui.item.id);
                            self._trigger("selected", event, {
                                item: select.find("[value='" + ui.item.id + "']")
                            });

                        },
                        minLength: 0
                    })
                    .addClass("ui-widget ui-widget-content ui-corner-left");

                    // This line added to set default value of the combobox
                    input.val(jQuery("#"+select.attr("id")+" :selected").text() )

                    $("<button>&nbsp;</button>")
                    .attr("tabIndex", -1)
                    .attr("title", "Show All Items")
                    .insertAfter(input)
                    .button({
                        icons: {
                            primary: "ui-icon-triangle-1-s"
                        },
                        text: false
                    }).removeClass("ui-corner-all")
                    .addClass("ui-corner-right ui-button-icon")
                    .click(function() {
                        // close if already visible
                        if (input.autocomplete("widget").is(":visible")) {
                            input.autocomplete("close");
                            return false;
                        }
                        // pass empty string as value to search for, displaying all results
                        input.autocomplete("search", "");
                        input.focus();
                        return false
                    });
                }
            });

    })(jQuery);

    $(function() {
            $("#id_software").combobox();
            $("#id_script").combobox();

    });



</script>


<body>
    <div>
        <form action="/followup/forms/runs/8/" method="post">
            <p><label for="id_software">Software:</label> <select name="software" id="id_software">

                    <option value="">---------</option>
                    <option value="1" selected="selected">AS_1500_211</option>
                    <option value="2">AS_1500_212</option>
                    <option value="3">AS_1500_213</option>
                    <option value="4">AS_1500_214</option>
                </select></p>
            <p><label for="id_script">Script:</label> <select name="script" id="id_script">
                    <option value="">---------</option>
                    <option value="1">OBJECT__1_TC1</option>

                    <option value="2">OBJECT__2_TC1</option>
                    <option value="3">OBJECT__2_TC2</option>
                    <option value="4">OBJECT__3_TC1</option>
                    <option value="5">OBJECT__3_TC2</option>
                    <option value="6">OBJECT__4_TC1</option>
                    <option value="7">OBJECT__4_TC2</option>
                </select></p>
            <input type="submit" value="Submit" />
        </form>

    </div>
</body>

(函数($){
$.widget(“ui.combobox”{
_创建:函数(){
var self=这个;
var select=this.element.hide();
变量输入=$(“”)
.insertAfter(选择)
.自动完成({
来源:功能(请求、响应){
var matcher=new RegExp(request.term,“i”);
响应(select.children(“option”).map(函数(){
var text=$(this.text();
if(this.value&(!request.term | | matcher.test(text)))
返回{
id:这个值,
标签:text.replace(新RegExp((?![^&;]+;)(?!(?![^&;]+;)),“gi”),“$1”,
值:文本
};
}));
},
延迟:0,
更改:功能(事件、用户界面){
如果(!ui.item){
//删除无效值,因为它与任何内容都不匹配
$(此).val(“”);
返回false;
}
选择.val(ui.item.id);
自触发(“选定”,事件{
项:选择.find(“[value=”+ui.item.id+“]”)
});
},
最小长度:0
})
.addClass(“ui小部件ui小部件内容ui左角”);
//添加此行以设置组合框的默认值
input.val(jQuery(“#”+select.attr(“id”)+“:selected”).text())
$(" ")
.attr(“tabIndex”,-1)
.attr(“标题”、“显示所有项目”)
.insertAfter(输入)
.按钮({
图标:{
主要:“ui-icon-triangle-1-s”
},
文本:false
}).removeClass(“用户界面角全部”)
.addClass(“ui右角ui按钮图标”)
。单击(函数(){
//如果已经可见,请关闭
如果(input.autocomplete(“小部件”)为(“:可见”)){
输入。自动完成(“关闭”);
返回false;
}
//将空字符串作为要搜索的值传递,显示所有结果
input.autocomplete(“搜索”和“);
input.focus();
返回错误
});
}
});
})(jQuery);
$(函数(){
$(“#id_软件”).combobox();
$(“#id_脚本”).combobox();
});
软件:
---------
AS_1500_211
AS_1500_212
AS_1500_213
AS_1500_214

脚本: --------- 对象\uuu1\uTC1 对象2\u TC1 对象\uuu2\uTC2 对象3\u TC1 对象3\u TC2 对象\uuu4\uTC1 对象\uuu4\uTC2


所以我知道这是一篇老文章,但我在这里看不到答案。我相信您需要的是一个名为livequery的jquery插件。它将允许您将jQueryUI特性添加到表中,该表通过等待它们存在于dom中来动态加载

当前:

$(function() {
        $("#id_software").combobox();
        $("#id_script").combobox();
});
使用livequery:

$(function() {
        $("#id_software").livequery(function() { $(this).combobox(); });
        $("#id_script").livequery(function() { $(this).combobox(); });
});

所以我知道这是一篇老文章,但我在这里看不到答案。我相信您需要的是一个名为livequery的jquery插件。它将允许您将jQueryUI特性添加到您的表中