Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <script type="text/javascript" src="../Scripts/libs/select2/select2.min.js"></script>
  2. <!-- Select2 CSS -->
  3. <link rel="Stylesheet" type="text/css" href="../Scripts/libs/select2/select2.css" />
  4. <link rel="Stylesheet" type="text/css" href="../Scripts/libs/select2/select2-bootstrap.css" />
  5.  
  6.  
  7.  
  8.  
  9. function SetCustomPeoplePicker() {
  10. $("#peoplePickerDiv").select2({
  11. placeholder: "Search for a person",
  12. minimumInputLength: 3,
  13. ajax: {
  14. url: $.QueryString["SPAppWebUrl"] + "/_api/web/siteusers",
  15. dataType: "json",
  16. data: function (term, page) {
  17. return {
  18. "$filter": "substringof('" + term + "', Title)"
  19. };
  20. },
  21. results: function (data, page) {
  22. return { results: data.d.results };
  23. },
  24. params: {
  25. contentType: "application/json;odata=verbose",
  26. headers: {
  27. "accept": "application/json;odata=verbose"
  28. }
  29. }
  30. },
  31. id: function (person) { return { id: person.Id }; },
  32. formatResult: function (person) {
  33. return person.Title;
  34. },
  35. formatSelection: function (person) {
  36. return person.Title;
  37. },
  38. formatNoMatches: function () {
  39. return "No people found. (Case Sensitive)";
  40. },
  41. escapeMarkup: function (m) { return m; },
  42. dropdownCssClass: "bigdrop"
  43. }).on('change', function (e) {
  44. // Access to full data
  45. console.log($(this).select2('data'));
  46. });
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement