cho*_*wwy 5 jquery jquery-ui jquery-ui-autocomplete
我正在使用具有多个结果和远程数据源的jquery自动完成.我能够远程提取数据并选择多个结果.但结果列表不会根据输入的前2个字符进行更新,并且jQueryUI文档在此问题上很薄.
我已经研究过,在SO上找到了这个答案,并希望将它与我的其余功能集成,但它不会更新结果列表.独立地,SO答案可以正常工作,但是当与多个结果和远程数据源集成时则不行.
从自动完成/远程源/多功能(截断).这部分工作正常:
.autocomplete({
                source: function( request, response ) {                            
                     $.ajax({
                        url: "/controller/myfunction",
                        dataType: "json",
                        data: request,
                        success: function(data){
                        if(data.response == 'true') {
                            response(data.message);
                            }
                        }
                    });
                },
在SO上可能的解决方案 :(独立工作正常,但不能使用jquery/remote/multiple代码):
var wordlist= [ "about", "above", "within", "without"];
$("#input1").autocomplete({
    source: function(req, responseFn) {
        var re = $.ui.autocomplete.escapeRegex(req.term);
        var matcher = new RegExp( "^" + re, "i" );
        var a = $.grep( wordlist, function(item,index){
            return matcher.test(item);
        });
        responseFn( a );
    }
});
我需要将此解决方案与我的代码集成.