I have the following problem, I have two fields to autocomplete (group name and number of the same) and the logical part works correctly but it does not show me the coincidences, as you can see the values appear in the console, but not in the page.
This is the code in the logic (PHP -Laravel 5.2)
public function groupNumber(){ $queries = Group::where(function($query){ $query->where('number','like','%'.Input::get('term').'%'); })->take(5)->get(); foreach ($queries as $query) { $results[$query->id] = $query->number; } return response()->json(['item' =>$results]); }
This is the jquery code
$('#txtGroupNumber').on('keypress',function(){ $('#txtGroupNumber').autocomplete({ source: '../autocomplete/groupNumber', minLength:3, select: function(event,ui){ $('#txtGroupNumber').val(ui.item.value); } }); $('#txtGroupNumber').data('ui-autocomplete')._renderItem = function(ul,item){ var $li = $(''); $li.attr('data-value',item.value); $li.append(""+item[1]); console.log(item); return $li.appendTo(ul); } });