Created
March 4, 2016 20:07
-
-
Save andervilo02/562f04d623892b64fc82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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