$("#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] + " <" + userData[i].split(":")[1] + "></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
-
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. :-)VulgarBinary– VulgarBinary2011年02月25日 22:34:05 +00:00Commented 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.VulgarBinary– VulgarBinary2011年03月02日 16:43:58 +00:00Commented Mar 2, 2011 at 16:43
-
Hmm, I think reading the documentation thoroughly helped :) Thanks! :)Pradeep Nayak– Pradeep Nayak2011年03月04日 20:24:37 +00:00Commented Mar 4, 2011 at 20:24
1 Answer 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);