Prime UI autocomplete

495 views Asked by At

I use laravel 5 and autocomplete from Prime UI:

  $(function() {
  $('#remote').puiautocomplete({  
        effect: 'fade',  
        effectSpeed: 'fast',  
        completeSource:function(request, response) {  
            $.ajax({  
                type: "GET",  
                url: "{{ URL::to('search/autocomplete') }}",  
                data: {query: request.query},  
                dataType: "json",  
                context: this,  
                success: function(data) {  
                    response.call(this, data);  
                }  
            });  
        }  
    });  

The input field:

  <input id="remote" name="remote" type="text"/>  

Through the given URL the following function is called:

  public function autocomplete(Request $request){
    $term = $request->input('remote');

   $results = array();
   $queries = DB::table('persons')
                    ->where('name', 'LIKE', '%' . $term . '%')
                    ->take(5)->get();
    foreach ($queries as $person) {

        $results[] = [ 'value' => $person->id, 'label' => $person->name];

    }

    return response()->json($results);
}

The problem is that when I have for example in my database 3 persons called Tom, Peter, Frank then by typing 'FR' in the input text field all 3 persons are shown for selection. Through the prime ui component the letters 'FR' are highlited as found. But only Frank should be visible for selection in such a case.

Any ideas what could be wrong? Thank you

0

There are 0 answers