[ 9 posts ]

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Autocomplete - lag issue

Post Posted: Tue Apr 24, 2012 1:42 pm
+1-
**** EDIT - see last post

I've implemented the YUI autocomlete before. The JSON array was built by looping through a resultset or users. And that works fine.

Now i'm trying to extend that. Now I only want certain users from the original data source. So I added a 2nd loop inside the first to compare the users in the original data source to my subset of users. It works, but it's a fair bit slower. I can accept the performance hit, but there's a weird little glitch. If you type each letter slowly you will get the correct result, but then it refreshes and shows previsous results from previous keystrokes. For example, if I type "c" ... "o"... "n" waiting 1 sec between each keystroke, the correct result shows for "con". Then it refreshes and shows the results for "co" then refreshes again and shows the results for "c".

I wish I could avoid the double loop. But, unfortunalety it's 2 separate data sources. The original data source is from a database and the other comes from Active Directory.


Last edited by reggi on Fri Apr 27, 2012 11:24 am, edited 3 times in total.

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Wed Apr 25, 2012 10:22 am
+1-
I think I can get all the data I need from active directory so I don't even have to use the other database. I'll put this into 1 resultset and i'll be back to creating the JSON with 1 loop instead of a double loop, which works fine with the YUI autocomplete.

Not sure why the autocomplete can't handle a double loop, but it's not something you should be doing anyway i guess.

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Thu Apr 26, 2012 5:00 am
+0-
Ok, I've only got the 1 loop now. Everything works, EXCEPT, the first keystroke shows the list alphabetically. Then on the 2nd keystroke it's in order. To troubleshoot. I removed my service call and loop and hard coded the JSON array. And it still shows the JSON array as it is originally instead of showing the correct list based on keystroke. What am I missing here? Is there some initial call?

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Thu Apr 26, 2012 9:54 am
+0-
To clarify, on the 1st keystoke it's returning the max result of the JSON array from the beginning of the array sequentially. On subsequent keystrokes I get the correct results. Example. I type "b" I get max results in original sort order. Next I type "i", then I get the correct results starting with "bi". If I backspace to just "b" I get the correct results. Even if I clear it and type "b" again I get the correct resuls (items starting with "b"). Selecting items from the list never works. It just clears the textbox. I'm guessing that's related to my problem. I've tried messing with the delay, and minimum characters, doesn't work.

To summarize. I have a working version of autocomplete that queries the database, creates a resultset. Then loop out the resultset creating the JSON on-the-fly.

So, instead of querying the database, i'm using JAVA to query active directory, but ultimately i'm creating a resultset the same way, but it doesn't work. I've looked at the resultset with both versions and it looks correct. The JSON must be in the right format or it would never work. I don't get what the difference is here. Ultimately is a JSON array. Both created on-the-fly with the AJAX call.

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Thu Apr 26, 2012 10:24 am
+0-
Ok, back to hardcoded JSON (validated JSON)
https://gist.github.com/2501627

And here's my javascript
https://gist.github.com/2501617

I still have the bug described above. 1st query entered brings back everything. Do the same query again, works.

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Fri Apr 27, 2012 5:36 am
+0-
~Deleted


Last edited by reggi on Fri Apr 27, 2012 11:25 am, edited 1 time in total.

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Fri Apr 27, 2012 11:23 am
+0-
Ok forget my previous posts. I've set this up on a regular webserver with static JSON. Why doesn't this work? What do I have wrong?

https://gist.github.com/2512024
https://gist.github.com/2501617
https://gist.github.com/2501627

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Sun Apr 29, 2012 7:06 am
+0-
I guess it's a bug

Reggi Brayne

  • Username: reggi
  • Joined: Sat Aug 27, 2011 7:01 am
  • Posts: 14
  • Offline
  • Profile

Re: Autocomplete - lag issue

Post Posted: Thu May 03, 2012 10:44 am
+0-
Well, couldn't figure it out, so I upgraded to YUI 3 and it works fine now.
  [ 9 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