DWR and Scriptaculous Autocomplete Dropdown
On a current project I decided I wanted to do something different. One thing I've heard users ask for during design meetings over the years is the ability to have an autocomplete function on a dropdown in a form. On those occasions I would always deny the request in some politically correct fashion. Without AJAX I simply didn't have a good way to make something like that work.
Well that all changed with my current project. We are using DWR and Scriptaculous on this project and I start work everyday incredibly excited because of it. Both are so easy to use and make so many things that were hard before easy.
This leads me to this auotcomplete widget that I incorporated into the web application the other day. This sample code and documenation can be found at the DWR Hints and Tips site. It took me no time at all to get going and make it look and feel as I wanted. I highly recommend it if you are every looking for such a widget for one of your sites.
June 12th, 2006 at 12:15 am
Hi,
Are you caching the results in the client side? I integrated DWR with script aculo for autocompletion. But it is hitting the server everytime i press a letter. For example, if i press ‘A’, it is getting results for ‘A’ and if i press one more letter with ‘A’, it should not hit the server instead it should get it from the cache. Can you please tell me how if you implemented cache for this?. Also how you are invalidating and controlling the cache?
thanks,
Ramkumar
June 13th, 2006 at 1:09 pm
I have not implemented a cache at all at this point on the client. This is still in the dev. stage with me. I’m starting SIT in a couple weeks to see how well it holds up. One on the client would not be so easy for me because I do not consider myself a JavaScript guru.
However, a way would be to customize the populateAutocomplete() function. Simple save the results from with first call to an array(hashtable?). Check if that list is null on subsequent calls and if not than search your cached list with a js regex call. clear/create your initial list on page load. I’m sure that over simplifies things but that is my thought process.
July 6th, 2010 at 10:25 am
http://localhost