Created
September 4, 2019 05:05
-
-
Save mohitrajput/c976e3d5f4b9cc7682f99f4179273f35 to your computer and use it in GitHub Desktop.
EdgeVerve : Ajax Autocomplete
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
| $(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