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;开发者_如何学JAVA
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>
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");
});
...
精彩评论