I need to add an autocomplete to a input field in my app using phonegap. I am aware of the autocomplete widget that jquery has and I wanted to use that in my app too. What I need is for the autocomplete to look for strings based off a query made in the sqlite db I have installed on my tablet.
$("#searchInput").autocomplete({
source: "script_that_queries_the_db.php"
});
From another thread I got this, but since phonegap doesn’t use php, are we allowed to call a JS file similarly and make that query a function, for example
function getSitenames () {
//stuff in here to build an array to use by autocomplete
}
Any help will be appreciated.
EDIT: My JSON/Array I’ll be grabbing from the database will contain around 1900 entries at a time. Since autocomplete will always recall the source, I was hoping to do something like
SELECT name FROM sitenames WHERE name LIKE ?
and parse in the response.text each time and build the array like that. (Since the sitesnames table holds 1900+ entries)
So jQM doesn’t support autocomplete properly, I had to use this, https://github.com/commadelimited/autoComplete.js for a substitution. It essentially works the same, where I used:
source: function (text) { var arrayClients = findCleints(text); callback(arrayClients) },