jQuery UI Autocomplete .result不是函数的问题 [英] jQuery UI Autocomplete .result is not a function woes

查看:318
本文介绍了jQuery UI Autocomplete .result不是函数的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经进行了一些搜索,这似乎不是一个罕见的问题,但是发布的所有解决方案似乎都不适合我.

I've done some searching, and this seems to be a not uncommon problem, but none of the solutions posted seem to be working for me.

我尝试了几种不同的方法:

I've tried a few different methods:

jQuery(document).ready(function(){
    jQuery( "#on-good-terms-add-term" ).autocomplete({
        source: ongoodtermsavailableTags,
    });

    jQuery( "#on-good-terms-add-term" ).result(function(event, data, formatted) { alert(data); });
});

jQuery(document).ready(function(){
    jQuery( "#on-good-terms-add-term" ).autocomplete({
        source: ongoodtermsavailableTags,
    }).result(function(event, data, formatted) {
        alert(data);
    });

});

两者都给我同样的控制台错误.希望得到任何帮助.谢谢

Both give me the same console error. Would appreciate any assistance. Thanks

推荐答案

当用户使用 jQuery UI自动完成小部件,您可以使用选择"事件处理程序按如下所示初始化构造函数:

To trigger an event when the user selects a search result with the jQuery UI autocomplete widget, you can initialize your constructor as follows with an event handler for "select":

jQuery("#on-good-terms-add-term").autocomplete({
    source: ongoodtermsavailableTags,
    select: function(e, ui) {
         alert("User selected: " + ui.item.value);
    }
});

这篇关于jQuery UI Autocomplete .result不是函数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆