views:

41

answers:

3

Hi, 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

A: 

Try this:

$('#textbox').click(function() {
   $(this).trigger('focus');
});
Darin Dimitrov
it doesn't work
Luca Romagnoli
A: 

Give this a try:

var input = $('#myinput');

input.autocomplete(data, {minChars: 0});
input.focus(function(){ input.keypress(); });
Yi Jiang
+1  A: 

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