开发者

open autocompleter results' div on textbox click

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


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


Try this:

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


Give this a try:

var input = $('#myinput');

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜