Search code examples
javascriptjqueryautocompleteautosuggest

JQuery/Javascript autocomplete has a very minor bug! Can someone with javascript experience help me pelase?


I am using this JQuery autocomplete plugin. It works, and it's simple. But there's a slight problem...

$("#q").autocomplete('/misc/autocomplete/', {autoFill:false,multiple:true, multipleSeparator:''});

When that happens, everytime I push a key into #q, it will call that misc/autocomplete/ website. If I search for cat, it will call that website 3 times. However, instead of calling "c", then "ca", then "cat", it will pass 3 separate characters. Of course, this is not what I want.

misc/autocomplete/?q=c&limit=10&timestamp=1257895405420
misc/autocomplete/?q=a&limit=10&timestamp=1257895405420
misc/autocomplete/?q=t&limit=10&timestamp=1257895405420

I have tried appending the $("#q").val() to the end of the URL part...but no luck. still the same. Can anyone tell me how to fix this auto-complete?


Solution

  • Have you seen the minChars property?

    You can pass in a value to specify the minimum number of characters a user has to type before the autocompleter activates.

    Did you see the other options you can set too (click on the options tab)

    EDIT:

    As I pointed out in the comments, you're using a '' for a multiple separator, therefore the plugin assumes that c, a and t are all separate terms to search for. I think that you might want to amend this to something else, possibly ' '