views:

334

answers:

1

Hi,

I am using the Autocomplete plugin by Jorn.(bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) I wanted a dropdown as soon as I place my cursor in the input box (local values). I tried putting minChars as 0. It didn't seem to have much effect. I made the following change in the autocomplete code

.click(function() {
                // show select when clicking in a focused field
                if ( hasFocus++ > 0 && !select.visible() ) { /// I have changed it
to > 0 instead of 1.

And Also I wanted to have multiple values. But after the first value in the input box the drop down box wouldn't appear on click on the box. I have to enter atleast one character. So I made the following change

            // if the exact item exists, use it
            if (options.minChars == 0) {  // start of my code
                return data[""];
            } // end of my code
        if (data[q]) {
            return data[q];
        }

Not sure if this will break the autocomplete on an AJAX mode...now with this it is able to dropdown even after the first value already in the box. but now the entered value replaces the older value...so I had to make one last change.

               if (words.length > 1) {
             if (options.minChars == 0 && $input.val().indexOf(",") >= 0) {
        v = words.slice(0, words.length).join(options.multipleSeparator) + options.multipleSeparator + v;
               }else { 
      v = words.slice(0, words.length - 1).join(options.multipleSeparator) + options.multipleSeparator + v;
                    }

                }else{
                if ($input.val().indexOf(",") >= 0) {
 v = words.slice(0, words.length).join(options.multipleSeparator)
+ options.multipleSeparator + v;
                                        }
                                }
            }
            v += options.multipleSeparator;

so My request is do you find anything that could break the code. I can sent you the modified autocomplete.js for testing.

A: 

I'm facing the same problem here, nice solution .

Miroslav