Guest User

Untitled

a guest
Mar 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
  2.  
  3. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  4. <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
  5.  
  6. <input type="text" id="search-deal" />
  7. <script>
  8. $(document).ready(function(){
  9. $('#search-deal').autocomplete({
  10. source: function(request, response) {
  11. var data = {
  12. "success": true,
  13. "data": "http://easyautocomplete.com/resources/countries.json",
  14. "additional_data": {
  15. "pagination": {
  16. "start": 0,
  17. "limit": 5,
  18. "more_items_in_collection": true,
  19. "next_start": 5
  20. }
  21. }
  22. };
  23.  
  24. var datamap = data.data.map(function(i) {
  25. return {
  26. label: i.id + ' - ' + i.name,
  27. value: i.id + ' - ' + i.n,
  28. desc: i.title
  29. }
  30. });
  31.  
  32. var key = request.term;
  33.  
  34. datamap = datamap.filter(function(i) {
  35. return i.label.toLowerCase().indexOf(key.toLowerCase()) >= 0;
  36. });
  37.  
  38. response(datamap);
  39. },
  40. minLength: 1,
  41. delay: 100
  42. });
  43. });
  44. </script>
Add Comment
Please, Sign In to add comment