jQuery的自动完成与DWR [英] jquery autocomplete with dwr

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

问题描述

有没有人使用jquery自动完成插件与DWR作为数据源的尝试。

has anyone tried using jquery autocomplete plugin with DWR as data source.

我需要自动完成功能为我的网页,但我也使用DWR,而不是典型的Ajax调用。

i need autocompletion functionality for my page, but i am also using dwr instead of typical ajax call.

我发现对于这一环节,但我无法找到源头code这个!

i found one link regarding this, but i am unable to locate the source code for this!

http://www.nabble.com/-自动完成 - jquery-%2B-DWR-td22691104s27240.html

有人可以帮我查找此源和使用它吗?

can somebody please help me locating this source and using it?

关于

推荐答案

阿伦是对他的做法,但也需要它来改变一个小东西。我与DWR-3.0.0-RC2,jQuery的-1.7.2.min.js和jQuery-UI-1.8.23.custom.min.js进行了测试。
相反的:

Arun is right with his approach, but it could be needed to change a little thing. I tested it with DWR-3.0.0-RC2, jquery-1.7.2.min.js and jquery-ui-1.8.23.custom.min.js. Instead of:

$('#autoCompTxt').autocomplete(data) ;

定义的的参数:

$('#autoCompTxt').autocomplete({source:data});

此外,良好的答案可以稍微改善检查的 autoCompTxt 的长度。事情是这样的:

Moreover that good answer can be slightly improved checking the autoCompTxt length. Something like this:

$(function() {
    $('#autoCompTxt').keyup(function() {
        var val = $('#autoCompTxt').val();
        if(val.length>2) {  // check length
            TestService.ajaxAutoCompleteTest(val, function(data) {
                // handle successful DWR response
                $('#autoCompTxt').autocomplete({source:data});
            });
        } else {
            $('#autoCompTxt').autocomplete({source:[]});  // clean
        }
    });
});

当然,脚本和CSS进口和输入文本应保持(见阿伦的回答)。
    

Of course, script and css imports and input text should be kept (see Arun's answer).

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

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