1

我正在使用这个插件来自动完成

http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete

我希望当用户单击文本框时,所有结果的 div 都变得可见

我试过了,$("#textbox").search()但没有用

我能怎么做?

谢谢

4

3 回答 3

1

这是 farrukhaziz 关于如何将此功能添加到插件的教程:http: //plugins.jquery.com/node/10336

您将需要编辑插件源代码。

将“LaunchManual”部分添加到源的此部分。

        flushCache: function() { 
                return this.trigger("flushCache"); 
        }, 
        setOptions: function(options){ 
                return this.trigger("setOptions", [options]); 
        }, 
        unautocomplete: function() { 
                return this.trigger("unautocomplete"); 
        }, 
        launchManual: function() {                         //ADD THIS
                return this.trigger("launchManual"); 
        }

以及本节中的“LaunchManual”位:

        }).bind("flushCache", function() { 
                cache.flush(); 
        }).bind("setOptions", function() { 
                $.extend(options, arguments[1]); 
                // if we've updated the data, repopulate 
                if ( "data" in arguments[1] ) 
                        cache.populate(); 
        }).bind("unautocomplete", function() { 
                select.unbind(); 
                $input.unbind(); 
                $(input.form).unbind(".autocomplete"); 
        }).bind("launchManual", function() {              //ADD THIS
                if( !cache.load( $input.val() ) ) 
                { 
                        cache.flush(); 
                        cache.populate(); 
                } 
                lastKeyPressCode = KEY.DOWN; // equivalent of 40 (down arrow) 
                onChange(0, true); 
        });

然后您可以调用该函数以显示下拉列表:

$('#textbox').click(function() {
   $(this).launchManual();
});
于 2010-09-02T07:58:36.587 回答
0

试试这个:

var input = $('#myinput');

input.autocomplete(data, {minChars: 0});
input.focus(function(){ input.keypress(); });
于 2010-09-02T07:29:13.230 回答
0

尝试这个:

$('#textbox').click(function() {
   $(this).trigger('focus');
});
于 2010-09-02T07:13:00.447 回答