Hi all,
Finishing my time tracker project...
I've used jquery-ui to autocomplete some edit fields.
It works very well, but I have not figured how to force the autocomplete to happen when the page loads if the editbox is full.
I've done this:
$( function() {
$("#edUbi").autocomplete(
{
minlength: 1,
source: function(request, response) {
$.ajax({
url: "autocompleteDatasource.php",
dataType: "json",
data: {
term : request.term
},
success: function(data) {
response(data);
}
});
},
focus: function(event, ui)
{
$("#edUbi").val(ui.item.name);
return false;
},
select: function(event, ui)
{
var country = "";
if (ui.item.country != null) country = ui.item.country + '\n';
if (ui.item.id != null) id = ui.item.id;
$("#taUbi").val(country + id);
return false;
}
})
.autocomplete("instance")._renderItem = function(ul, item){
return $( "<li>" )
.append( "<div>" + item.name + "</div>" )
.appendTo( ul );
};
});
With this code, I can start typing into edUbi (the textBox) and a list appears with values that are like the written text.
Once I select an option from the list edUbi a textArea control gets filled with country and id (I've reduced the list, but all the location data is there).
Is it possible to execute the query and fill taUbi with the correct values when I load the page and the edUbi control gets filled?
How should I do it?
Any idea?
Thank you very much for your time and help!
What I have tried:
Multiple syntax, searched Internet to find a description of the way to do it without luck.