Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Username1, Username2, Username3
- $( "#message_recipient" ).autocomplete({
- source: function( request, response ) {
- if($('#message_recipient').val().indexOf(",") != -1){
- var pieces = $.trim($('#message_recipient').val()).split(/[s,]+/);
- var last_piece = $.trim(pieces[pieces.length-1]);
- } else {
- var last_piece = $.trim($('#message_recipient').val());
- }
- if(last_piece!=""){
- $.ajax({
- url: baseurl+"users/search_for_user",
- dataType: "json",
- type: "POST",
- data: {
- user_name: last_piece
- },
- success: function( data ) {
- response( $.map( data.result, function( item ) {
- return {
- label: item.user_name,
- value: item.user_name
- }
- }));
- }
- });
- }
- },
- minLength: 2,
- select: function( event, ui ) {
- $('#message_recipient').val($('#message_recipient').val()+ui.item.label+", ");
- },
- open: function() {
- },
- close: function() {
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement