agarzola / jQueryAutocompletePlugin

Jörn Zaefferer’s (now deprecated) jQuery plugin, with tweaks.
282 stars 151 forks source link

add an option to display the results onFocus #5

Closed fgosfacdjtq closed 13 years ago

fgosfacdjtq commented 13 years ago

Problem: as a user I'd like to see the list of results before I type anything. I should be able to click on the input box and have it bring up the first # results with out typing anything. At the current moment I have to double click on the input box for this to happen.

Line 146 should be changed to the following: }).focus(function(){ // track whether the field has focus, we shouldn't process any // results if the field no longer has focus hasFocus++; if (config.quickViewResults && !select.visible() ) { onChange(0, true); } ....

agarzola commented 13 years ago

Thank you for sharing your idea with me, fgosfacdjtq. I’ll take it into consideration in a future version.

fgosfacdjtq commented 13 years ago

For those looking to do so in the current version, here is my workaround

var gTrickClickFunc=0; //global variable search.click( function() { / * this makes sure that the click event is processes only twice and not 100+ times with a recursive loop / if (gTrickClickFunc++ == 0) { $(this).click(); gTrickClickFunc=0; } });

agarzola commented 13 years ago

Hi, fgosfacdjtq. Please specify where in the plugin you are inserting this code, for the benefit of users who may wish to experiment with your fix.

Also, for some reason github is not interpreting your markdown correctly, resulting in mis-quoted code. For those interested, here is fgosfacdjtq’s code:

var gTrickClickFunc=0; //global variable
search.click( function() {
    /*
     * this makes sure that the click event is processes only twice and not 100+ times with a recursive loop
     */
    if (gTrickClickFunc++ == 0)
    {
        $(this).click();
        gTrickClickFunc=0;
    }
});

Thanks!

agarzola commented 13 years ago

Hi again!

I just pushed this feature up. The behavior is false by default, but by adding clickFire: true to your options, the list of items will show up, granted that the minimum number of characters is met. That means that if you want it to happen without anything written in the textfield, you’ll need to set minChars: 0 in your options as well.

I’m closing this issue, but please let me know of any issues you may find.

Cheers.

fgosfacdjtq commented 13 years ago

Another quality fix. Works in FF3.5, Chrome 9, and IE8