Guest User

Untitled

a guest
Jan 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. <h4>search:<input type="text" id="name-list" /></h4>
  2. <script type="text/javascript" language="javascript">
  3. $(function () {
  4.  
  5. $("#name-list").autocomplete({
  6. source: function (request, response) {
  7. $.ajax({
  8. url: "/Home/Searchuser", type: "POST", dataType: "json",
  9. data: { searchText: request.term, maxResults: 10 },
  10. success: function (data) {
  11. response($.map(data, function (item) {
  12. return { label: item.DisplayName + " R:" + item.Reputation , value: item.DisplayName, id: item.Id }
  13. }))
  14. }
  15. })
  16. },
  17. select: function (event, ui) {
  18. alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.id)
  19. : "Nothing selected, input was " + this.value);
  20.  
  21.  
  22.  
  23.  
  24.  
  25. }
  26. });
  27.  
  28. });
  29. </script>
  30.  
  31. <style type="text/css">
  32. DIV.list_item_container {
  33. height: 90px;
  34. padding: 0px;
  35. }
  36. DIV.image {
  37. width:90px;
  38. height: 90px;
  39. float: left;
  40. }
  41. DIV.description {
  42. font-style: italic;
  43. font-size: 1.1em;
  44. color: gray;
  45. padding: 5px;
  46. margin: 5px;
  47. }
  48.  
  49. #name-list
  50. {
  51. width: 300px;
  52.  
  53.  
  54. }
  55. </style>
  56.  
  57. $(document).ready(function () {
  58. $('#name-list').autocomplete({
  59. source: function (request, response) {
  60. $.ajax({
  61. url: "/Home/Searchuser",
  62. data: { searchText: request.term, maxResults: 10 },
  63. dataType: "json",
  64. success: function (data) {
  65.  
  66. response($.map(data, function (item) {
  67. return {
  68. value: item.DisplayName,
  69. avatar: item.PicLocation,
  70. rep: item.Reputation,
  71. selectedId: item.UserUniqueid
  72. };
  73. }))
  74. }
  75. })
  76. },
  77. select: function (event, ui) {
  78.  
  79. alert(ui.item ? ("You picked '" + ui.item.label)
  80. : "Nothing selected, input was " + this.value);
  81.  
  82. return false;
  83. }
  84. }).data("autocomplete")._renderItem = function (ul, item) {
  85. var inner_html = '<a><div class="list_item_container"><div class="image"><img src="' + item.avatar + '"></div><div class="label"><h3> Reputation: ' + item.rep + '</h3></div><div class="description">' + item.label + '</div></div></a><hr/>';
  86. return $("<li></li>")
  87. .data("item.autocomplete", item)
  88. .append(inner_html)
  89. .appendTo(ul);
  90. };
  91.  
  92.  
  93. });
Add Comment
Please, Sign In to add comment