As I commented, you can do this using a Function for source.
Working Example: https://jsfiddle.net/Twisty/5gm0tmLh/
JavaScript
var mySource = [{
value: "Equipment Search",
url: 'https://domaina.com/equipment/default.aspx'
}, {
value: "Equipment Search Dev",
url: 'https://domaina.com/equipment/default.aspx'
}, {
value: "Equipment Search QA",
url: 'https://domaina.com/equipment/default.aspx'
}, {
value: "FCSF",
url: 'http://domainb.com/aspnet35/POSLogin/Login.aspx?AppName=Console&ConsoleApp=CSF'
}, {
value: "Hitch Matrix",
url: 'https://domainc.com/secure/aspnet4/hitchmatrix/manage_hitches.aspx'
}, {
value: "Kiosk Dev",
url: 'http://domainc.com/aspnet3/kioskadmin/'
}, {
value: "Kiosk",
url: 'https://domaina.com/secure/kioskadmin/'
}, {
value: "MOAS",
url: 'https://domaina.com/tools/inventory_control/login_main.aspx?ReturnUrl=%2ftools%2finventory_control%2fOrderApproval.aspx%20'
}, {
value: "POS Admin",
url: 'https://domainb.com/POSAdmin'
}, {
value: "QA Tool Dev",
url: 'http://domainc.com/aspnet4/NewQAAdmin/login.aspx'
}, {
value: "QA Tool",
url: 'https://domaina.com/QAAdmin/login.aspx'
}, {
value: "RT Admin Tool",
url: 'https://domaina.com/secure/rta/login/adminlogin'
}, {
value: "Uchat Dev",
url: 'https://domaina.com/tools/uchat_app/publish.htm'
}, {
value: "Uchat",
url: 'https://domaina.com/tools/uchat_app/publish.htm'
}, {
value: "Uscan Service Logger (Dev)",
url: 'http://mdomainc.com/aspnet4/ServiceLogger/'
}, {
value: "Uscan Service Logger",
url: 'https://domainc.com/secure/aspnet4/ServiceLogger'
}, {
value: "VIP Look Up",
url: 'https://domaina.com/tools/certificate/default.aspx'
}, ];
$(function() {
$("input.autocomplete").autocomplete({
minLength: 1,
source: function(req, resp) {
var q = req.term;
var myResponse = [];
$.each(mySource, function(key, item) {
if (item.value.toLowerCase().indexOf(q) === 0) {
myResponse.push(item);
}
});
resp(myResponse);
},
select: function(event, ui) {
window.open(ui.item.url);
}
});
});
From the API:
Function: The third variation, a callback, provides the most flexibility and can be used to connect any data source to Autocomplete. The callback gets two arguments:
A request
object, with a single term
property, which refers to the value currently in the text input. For example, if the user enters "new yo"
in a city field, the Autocomplete term will equal "new yo"
.
A response
callback, which expects a single argument: the data to suggest to the user. This data should be filtered based on the provided term, and can be in any of the formats described above for simple local data. It's important when providing a custom source callback to handle errors during the request. You must always call the response
callback even if you encounter an error. This ensures that the widget always has the correct state.
When filtering data locally, you can make use of the built-in $.ui.autocomplete.escapeRegex
function. It'll take a single string argument and escape all regex characters, making the result safe to pass to new RegExp()
.
Hope that helps.