else $("#actiontrigger").attr('href', "sms://"+encodeURI( data.join(';') ))[0].click(); }, error: function(err,msg){ alert(err); alert(msg); return false; } }); }); var names = jQuery.parseJSON( '<?php echo str_replace("'", "\\'", json_encode($ATC->get_activity_names())); ?> ' ); $('#title').autocomplete({ source: names, minLength: 0 }); var locations = jQuery.parseJSON( '<?php echo str_replace("'", "\\'", json_encode($ATC->get_locations())); ?> ' ); // Autocompletes need a label field to search against $.each(locations, function(){ $(this)[0].label = $(this)[0].name + " " + $(this)[0].address; }); $('#location').autocomplete({ minLength: 0, source: locations, focus: function( event, ui ) { $( "#location" ).val( ui.item.name ); return false; }, select: function( event, ui ) { $( "#location" ).val( ui.item.name );