views:

260

answers:

2

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

+1  A: 

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 ' '

Russ Cam
Yes, I know what that is, but how can I use that to solve the problem that the plugin is only sending 1 character at a time? instead of appending the character?
TIMEX
Are you using a `''` for a multiple separator? If so, the plugin would be assuming that **c**, **a** and **t** are also separate words to search for
Russ Cam
+2  A: 

That's not a bug, it's the behavior according to the specified options.

You specified multiple: true making the plugin accept several search terms, but then you define the term separator as multipleSeparator: '', meaning that there isn't any separator and therefore each character is an individual search term, which is probably not what you want, but it's what the plugin is giving you.

Check out the Plugin's Documentation for more details on the options you provided to it.

Miguel Ventura
Thanks, you and Russ are correct.
TIMEX