The code I'm writing does not display the autocomplete multiple value that were already retrieve successfully by Ajax. my html for display is
<input type="text" name="s_to" id="s_to" class="controls">
My jquery:
<script>
$("#s_to").keyup( function() {
url = "<?php echo base_url(); ?>index.php/<?php echo $loc_pts; ?>/ajax_email";
$( "#s_to" ).autocomplete({
source: function( request, response ) {
var s_to = extractLast(request.term);
$.ajax({
url: url,
type: "POST",
data: {s_to: s_to},
dataType: "json",
success:function(response) {
response.s_to;
}
});
},focus: function() {
return false;
},
select: function( event, ui ) {
var terms = split( $('#s_to').val() );
terms.pop();
if(duplicate($('#s_to').val(), ui.item.label)){
terms.push( ui.item.label );
terms.push( "" );
$('#s_to').val(terms.join( ", " ));
}
return false;
}
});
});
function duplicate(f,s){
if( f.match(new RegExp("(?:^|,)"+s+"(?:,|$)"))) {
return false;
}else{
return true;
}
}
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
I expect I can insert multiple input in a textbox but no selection were being output. Thus I cannot autocomplete the input either by clicking or keyboard arrow keys