jQuery自动完成& quot;响应& quot;事件 [英] jQuery autocomplete "response" event

查看:73
本文介绍了jQuery自动完成& quot;响应& quot;事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用[http://api.jqueryui.com/autocomplete/]所述的jQuery UI自动完成

I'm using jQuery UI autocomplete as described [http://api.jqueryui.com/autocomplete/]

在执行搜索之前和之后,我需要做一些事情.通过阅读上述URL上的文档,它描述了两种方法搜索"和响应",这两种方法在查询运行之前和之后都被触发-完美.但是,如果我将它们添加到我的代码中,则搜索"可以完美地工作,但是永远不会调用响应".我究竟做错了什么?我所有的代码都可以正常工作,没有javascript错误,自动完成功能非常完美.但是我从来没有触发过响应"方法.

I need to do a few things before and after the search is executed. From reading the documentation at the above URL it describes two methods "search" and "response," that are triggered before and after the query is run - perfect. BUT, if I add these to my code, "search" works perfectly, but "response" is never called. What am I doing wrong? All my code works, no javascript errors, autocomplete works perfectly. But I just dont ever have the "response" method being triggered.

$(function() {
             $("#tv").autocomplete({
                source: "a_url_providing_json",
                minLength: 4,
                select: function(event, ui) {
                    $('#state_id').val(ui.item.id);
                    $('#abbrev').val(ui.item.abbrev);
                },
                search : function(a,b) {
                     alert('this works!');
                },
                response : function(a,b) {
                     alert('this doesnt!');
                } 
        })    
    }); 

非常感谢您的任何建议!

Many thanks for any advice !

推荐答案

此回调方法随新的jquery-ui一起提供.我无法使它正常工作,但是在我将 1.8.20 更新为 1.9.2 后,回调按预期方式触发.

This callback-method arrived with the new jquery-ui. I could not get this to work, but after i updated from 1.8.20 to 1.9.2 the callback fires just as it is supposed to.

希望有帮助!

这篇关于jQuery自动完成& quot;响应& quot;事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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