javascript - Laravel 5.1 typeahead.js unable to find any data -


i'm using laravel 5.1 , try add autocomplete form, not return error it's return unable find any. i'm new in javascript. please me fix it

here template:

{!! form::label('name', 'name:') !!} {!! form::text('name',null,['class'=>'form-control', 'id'=>'users']) !!} 

here route :

route::get('/', 'searchcontroller@index'); route::get('/query','searchcontroller@query'); 

here controller

class searchcontroller extends controller {      public function index() {         return view::make('template');     }      public function query() {         $query = input::get('name');         $res = user::where('name', 'like', "%$query%")->get();         return response::json($res);     }  } 

here main.js

jquery(document).ready(function($) {     var sugest = new bloodhound({         remote: '/bookstore/query?name=%query%',         // '...' = displaykey: '...'         datumtokenizer: bloodhound.tokenizers.whitespace('name'),         querytokenizer: bloodhound.tokenizers.whitespace     });      sugest.initialize();      $("#users").typeahead({         hint: true,         highlight: true,         minlength: 2     }, {         source: sugest.ttadapter(),         name: 'engine',         displaykey: 'name',         templates: {             empty: [                 '<div class="empty-message">unable find any</div>'             ]         }     }); }); 

can suggest autocomplete javascript library. how select2. here link. https://select2.github.io/examples.html . it's easy implement. used typeahead before , took me day or 2 work.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -