打开自动完成结果文本框上的 div 单击

发布于 2024-09-16 15:06:30 字数 319 浏览 3 评论 0原文

我正在使用此插件进行自动完成

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

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

我已经尝试过 $("#textbox").search()但不起作用

我该怎么办?

谢谢

i'm using this plugin for autocomplete

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

i want that when the user clicks on the textbox the div with all results become visible

i' ve tried with $("#textbox").search() but doesn't work

How can i do?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绻影浮沉 2024-09-23 15:06:31

试试这个:

$('#textbox').click(function() {
   $(this).trigger('focus');
});

Try this:

$('#textbox').click(function() {
   $(this).trigger('focus');
});
樱娆 2024-09-23 15:06:31

尝试一下:

var input = $('#myinput');

input.autocomplete(data, {minChars: 0});
input.focus(function(){ input.keypress(); });

Give this a try:

var input = $('#myinput');

input.autocomplete(data, {minChars: 0});
input.focus(function(){ input.keypress(); });
記憶穿過時間隧道 2024-09-23 15:06:30

以下是 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();
});

Here is a tutorial by farrukhaziz on how to add this functionality to the plugin: http://plugins.jquery.com/node/10336

You will need to edit the plugin source code.

Add the 'LaunchManual' part to this section of the source.

        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"); 
        }

and the 'LaunchManual' bit in this section:

        }).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); 
        });

Then you can call the function to show the dropdown:

$('#textbox').click(function() {
   $(this).launchManual();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文