views:

49

answers:

3

Hi all,

I am using Jquery autocomplete with local array of size ~5000, every word is ~10 chars. I am initializing the object like this:

.autocomplete({matchContains: true, minLength: 3, delay: 700, source: array1, max: 10, highlight: true })

The problem is, that when I start to type, it takes a lot of time (sometime crashes the browser) until the result is displayed.

What can I do?

Thanks

+1  A: 

You could use AJAX to fetch the array instead of putting it into the HTML, increase the delay and the required minLength before querying the server in order to reduce the matches.

Darin Dimitrov
A: 

Are you using the standard jQuery autocomplete plugin? If so, I'm unfamiliar with the option parameter "source" that you used.

The proper syntax for that plugin is: autocomplete( url or data, [options] ). It sounds like your version works with the 'source' option parameter,(although while crashing the browser) so I'm confused. If the browser is crashing, I'd expect the problem to be related to the javascript.

I recommend trying:

$('whatever').autocomplete(array1,{
    matchContains: true, 
    minLength: 3, 
    delay: 700,  
    max: 10, 
    highlight: true 
});
kevtrout
+1  A: 

I would do like Darin Dimitrov said, but I would also do a .Take(10) (or some arbitrary number that sounds good to you) in a quick linq statement on the server side. This would lessen the result set and would still become more accurate as the user continues to type.

Greg Kurts