dimanche 4 mars 2018

Laravel 5 Type ahead not firing

! am attempting to get a simple typeahead working. I have a form with the followiong:

<div class="form-group">
     <input class="typeahead form-control" style="margin:0px;auto;width:300px;" type="text">
</div>

In my form I am loading the appropriate file (jQuery is loaded in the main layout):

<script src=""></script>
<script>
var path = "";
  $('input.typeahead').typeahead({
      source:  function (query, process) {
      return $.get(path, { query: query }, function (data) {
              return process(data);
          });
      }
  });
  </script>

i have set up a route:

Route::get('autocomplete','TestController@autocomplete')->name('autocomplete');

and the Test controller has the following:

public function autocomplete(Request $request)
  {
      $data = Countries::select("country as name")->where("country","LIKE","%{$request->input('query')}%")->get();
      return response()->json($data);
  }

I have Countries in the uses.

Nothing seems to happen!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oHX3HL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire