Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Username1, Username2, Username3
  2.  
  3. $( "#message_recipient" ).autocomplete({
  4. source: function( request, response ) {
  5. if($('#message_recipient').val().indexOf(",") != -1){
  6. var pieces = $.trim($('#message_recipient').val()).split(/[s,]+/);
  7. var last_piece = $.trim(pieces[pieces.length-1]);
  8. } else {
  9. var last_piece = $.trim($('#message_recipient').val());
  10. }
  11.  
  12. if(last_piece!=""){
  13. $.ajax({
  14. url: baseurl+"users/search_for_user",
  15. dataType: "json",
  16. type: "POST",
  17. data: {
  18. user_name: last_piece
  19. },
  20. success: function( data ) {
  21. response( $.map( data.result, function( item ) {
  22. return {
  23. label: item.user_name,
  24. value: item.user_name
  25. }
  26. }));
  27. }
  28. });
  29. }
  30. },
  31. minLength: 2,
  32. select: function( event, ui ) {
  33. $('#message_recipient').val($('#message_recipient').val()+ui.item.label+", ");
  34. },
  35. open: function() {
  36.  
  37. },
  38. close: function() {
  39.  
  40. }
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement