Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 自动完成和生活?_Javascript_Jquery Ui_Jquery_Jquery Ui Autocomplete - Fatal编程技术网

Javascript 自动完成和生活?

Javascript 自动完成和生活?,javascript,jquery-ui,jquery,jquery-ui-autocomplete,Javascript,Jquery Ui,Jquery,Jquery Ui Autocomplete,我有以下脚本,只要#txtAllowSearch是平面html,它就可以工作: $(document).ready(function(){ $("#txtAllowSearch").autocomplete({ source: "test_array.aspx", delay: 0, select: function (event, ui) { $("#txtAllowSearch").val(ui.item.val

我有以下脚本,只要#txtAllowSearch是平面html,它就可以工作:

$(document).ready(function(){
    $("#txtAllowSearch").autocomplete({
        source: "test_array.aspx",
        delay: 0,
        select: function (event, ui) {
            $("#txtAllowSearch").val(ui.item.value); // display the selected text
            $("#txtAllowSearchID").val(ui.item.id); // save selected id to hidden input
        }
    });
});
一旦javascript/jquery动态创建了#txtAllowSearch,它就会停止工作


我是否需要使用jqueries live来实现此功能?

jQuerys
.live()
/
.delegate()
仅捕获事件。在您的情况下(对元素应用插件方法),每次将元素插入DOM后都需要调用
.autocomplete()
,或者使用优秀的
.livequery
插件。

jQuerys
.live()
/
.delegate()
仅捕获事件。在您的情况下(对元素应用插件方法),您需要在每次将元素插入DOM后调用
.autocomplete()
,或者使用优秀的
.livequery
插件。

jQuery.live现在已被弃用

要实现这一点,您现在需要美元(document).on


有关更多信息,请参阅jQuery API文档:

jQuery.live现在已不推荐使用

要实现这一点,您现在需要美元(document).on


有关更多信息,请参阅jQuery API文档:

如果动态创建并插入了#txtAllowSearch,则可能是;如果动态创建并插入了#txtAllowSearch,则可能是;如果创建了#txtAllowSearch,则仅绑定该函数;如果创建了#txtAllowSearch,则可能是
$(document).ready(function(){
    $(document).on("focus.autocomplete", "#txtAllowSearch", function() {
        source: "test_array.aspx",
        delay: 0,
        select: function (event, ui) {
            $("#txtAllowSearch").val(ui.item.value); // display the selected text
            $("#txtAllowSearchID").val(ui.item.id); // save selected id to hidden input
        }
    });
});