Skip to content

Instantly share code, notes, and snippets.

@amusarra
Created September 29, 2014 16:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save amusarra/b9605e831ace05ac5886 to your computer and use it in GitHub Desktop.
AUI Auto Complete by Ajax via POST
var dataSource = new A.DataSource.IO(
{
source: '<%=getAccountResourceURL%>',
ioConfig: {
method: 'post',
}
}
);
var autoComplete = new A.AutoComplete(
{
dataSource: dataSource,
delimChar: '',
contentBox: '#accountCombo',
matchKey: 'description',
schema: {
resultListLocator: 'response',
resultFields: ['key','codice','description']
},
schemaType:'json',
typeAhead: true,
queryDelay: 1,
cssClass: 'ac_input',
id: 'accountComboField'
});
autoComplete.generateRequest = function(query) {
if(query.indexOf('*') != -1 && query.length > 1) {
query = "*";
var account = AUI().one('#accountComboField input');
if(account) {
account.val("");
}
}
return {
request: '&<%=WebKeys.ACCOUNT_SEARCH_KEY_DESCRIPTION%>=' + query
};
}
autoComplete.render();
A.ready(
function() {
var account = AUI().one('#accountComboField input');
if(account) {
account.val("<%=accountDescription%>");
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment