0
 $("#caller__MODULE_ID__").focus().autocomplete(userData, {
 minChars: 0,
 max:4,
 width: "20%",
 matchContains: true,
 cacheLength: 0,
 selectFirst: false,
 autoFill: false,
 formatMatch: function(row, i, max) {
 return "<table class='tbl-ac' border='0' cellpadding='0' cellspacing='0'><tr><td>"+ userData[i].split(":")[0] + " &lt;" + userData[i].split(":")[1] + "&gt;</td></tr></table>";
 },
 formatResult: function(row) {
 var rowString = row+"";
 return rowString.split(":")[0];
 }
 });

Problem: Whenver I clear the text box , the first four entries of the autocomplete list are always displayed. How to eliminated them

I also noticed that when I hit a tab it clears. I tried a keypress event and that did not help too. See code below for keypress

$("#caller__MODULE_ID__").bind("keypress",function(event){
 if($("#id").text()=="")
 {
 myEvent = jQuery.Event("keypress");
 myEvent.keyCode= 9;
 $("#caller__MODULE_ID__").trigger(myEvent);
 }
 });

PS: Tried on a firefox browser

asked Feb 25, 2011 at 20:13
3
  • Be sure that when you are finished with this question you accept an answer! Dead questions that never get answered accepted are a bad thing. :-) Commented Feb 25, 2011 at 22:34
  • please do not let questions sit idle without any further activity or questions remaining. If this question is completed, please accept an answer. If you still have questions please specify what questions you still have. Commented Mar 2, 2011 at 16:43
  • Hmm, I think reading the documentation thoroughly helped :) Thanks! :) Commented Mar 4, 2011 at 20:24

1 Answer 1

1

You really need to take another look at the official documentation for autocomplete, the reason you are having problems is a lot of the added parameters that you are adding. (Including the formatMatch method you are calling, might I ask why exactly you are formatting it as a table?!)

All you really need to specify is the element to setup autocomplete on and the user-data, start there at the absolute raw start, and start adding back in your parameters. That will take you to the root cause of your error.

If you'd like me to debug a bit more for you please post your FULL code and I will jump through it to see what's causing your error.

Resource: http://docs.jquery.com/Plugins/autocomplete

Edit: (Add the bare bones of how this component works)

$("#caller__MODULE_ID__").autocomplete(userData);

answered Feb 25, 2011 at 20:27
Sign up to request clarification or add additional context in comments.

3 Comments

VulgarBinary, May I know your name :) Yes I know table is an absolute waste. I know that can be removed. userdata is a concatenation of two js variables of the form <username>: <LastName, FirstName>.. something of this sort.
>>All you really need to specify is the element to setup autocomplete on and the user-data, start there at the absolute raw start -- how do i go about this??
Updated, the move you make now is one by one add back in your additional options. Check the JQuery documentation on the plugin for how to add them in. Let me know if you have any other issues.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.