views:

358

answers:

2

I am using a jquery autocomplete and i have a keyup event for my textbox. When I enter in a letter the function is called but the box is not populated.

Once I click away from the box and then click back into it the autocomplete works great.

Really weird issue and I have no idea how to fix it. Any help would be appreciated.

here's my code

$(document).ready(function(){

  var x;
  var output;
  x = document.getElementById('site').value; 

  $.getJSON(url,{field: "name",value: x, comparison: "LIKE"},  
    function(json){    
      //code to format output
      $("#site").autocomplete(output, json);   
  });  
});



<input type ="text" size ="40" id="site"></input> 
A: 

What confuses my is that the documentation of the plugin say

autocomplete(url or data, options)

Shouldn't your call look like this? What is this output variable anyway?

$("#site").autocomplete(json, options)

Which autocomplete? Care to provide an url. Anyway did you try triggering the focus manually?

...
function(json){
    //code to format output
    $("#site").autocomplete(output, json).trigger("focus");
});
...
jitter
http://docs.jquery.com/Plugins/Autocompletei tried the focus trigger and didnt work
TheIG
Check expanded answer
jitter
in my case the json is the data. and the output variable "#site" is the id of the div where the results appear
TheIG
A: 

I am facing same problem. I tried the above solution It worked. $("#site").autocomplete(url).trigger("focus");