[ 3 posts ]

Gabe Moothart

YUI Contributor

  • Offline
  • Profile

Pre-loading a cascading autocomplete

Post Posted: Thu Jul 07, 2011 8:15 am
+0-
Here is my scenario: a user selects a county (from an autocomplete textbox) and then (in another autocomplete) is able to select one of the cities in that county.

I want to pull all cities in a county and do the filtering client-side (which makes sense for my use-case). Also, I want to start loading the cities in the county autocomplete's "select" event, rather than waiting for the user to tab over to the cities textbox, to improve perceived performance.

All that is working fine. Here is the issue: if a fast user enters the county, then tabs over to the city textbox and starts typing before the "pre-load" request comes back, it will issue a second one and then wait for that.

I would the city autocomplete to somehow recognize that a request is already in progress. Any ideas on how to accomplish that? My code is [gist=2b9093918fd7b619b2fe]here[/gist].

TIA,
Gabe

Ryan Grove

YUI Developer

  • Username: rgrove
  • Joined: Tue Dec 09, 2008 9:55 pm
  • Posts: 275
  • Location: Portland, OR
  • Twitter: yaypie
  • GitHub: rgrove
  • Gists: rgrove
  • IRC: rgrove
  • YUI Developer
  • Offline
  • Profile

Re: Pre-loading a cascading autocomplete

Post Posted: Thu Jul 07, 2011 9:41 am
+0-
Thinking from an interaction design perspective, wouldn't it make more sense to have a single input field for the city and then automatically determine the correct county based on the city the user enters?

In any case, I think the current design could be made to work by disabling city queries until the cache is primed. Here's a fork of your gist (untested, so beware) that demonstrates what I'm thinking: https://gist.github.com/ad3f4b928857600a8442

I also changed the way the city AutoComplete's requestTemplate was set. Instead of getting form values on every execution of the requestTemplate, there's now a utility function that returns a string template, and the requestTemplate value is updated when the template changes. This should be faster.

Gabe Moothart

YUI Contributor

  • Offline
  • Profile
Tags:

Re: Pre-loading a cascading autocomplete

Post Posted: Fri Jul 08, 2011 10:01 am
+0-
Thanks Ryan, that should work.
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum