Skip to content

Instantly share code, notes, and snippets.

@andervilo02
Created March 4, 2016 20:07
Show Gist options
  • Save andervilo02/562f04d623892b64fc82 to your computer and use it in GitHub Desktop.
Save andervilo02/562f04d623892b64fc82 to your computer and use it in GitHub Desktop.
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Auto Complete-jQuery-UI</title>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.theme.css">
</head>
<body>
<div class="ui-widget">
<input type="text" id="nometeste"/>
</div>
<script src="js/jquery.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
$(function(){
function getDados(array, campo){
return $.map(array, function(obj){
return ''+obj[campo]+'';
});
}
$.getJSON('http://localhost:3001/api',function(retorno){
var dados = getDados(retorno,'nome');
$('#nometeste').autocomplete({
source: dados
});
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment