Skip to content

Instantly share code, notes, and snippets.

@mohitrajput
Created September 4, 2019 05:05
Show Gist options
  • Select an option

  • Save mohitrajput/c976e3d5f4b9cc7682f99f4179273f35 to your computer and use it in GitHub Desktop.

Select an option

Save mohitrajput/c976e3d5f4b9cc7682f99f4179273f35 to your computer and use it in GitHub Desktop.
EdgeVerve : Ajax Autocomplete
$(document).ready(function(){
$('#<portlet:namespace/>country').on('keydown keyup',function(){
var data = [];
var text = $(this).val();
$('#<portlet:namespace/>country').autocomplete({
source: function(request,response){
Liferay.Service('/country/get-countries', {
active: true
},
function(obj) {
for(let i =0;i<obj.length;i++){
if(obj[i].name.indexOf(text) != -1){
data.push(obj[i].name);
}
}
response(data);
});
}
})
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment