I am unable to view the pre-populated drop-down list based on a value entered in the search field as the principle of google search: excerpt view administration.blade.php
<!-- Recherche -->
<section class="panel panel-default">
<header class="panel-heading">Recherche
<input type="text" name="keyword" id="keyword" class="form-control" placeholder="Rechercher">
</header>
<div class="panel-body">Autres imputs</div>
</section>
</form>
extract overview app.blade.php // header
<link href='//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css' rel="stylesheet">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
{!! Html::script('js/administration.js') !!}
{!! Html::script('//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js') !!}
Route file extract
Route::resource('administration', 'PrestationController');
Controller file extract
public function autocomplete(Request $request)
{
$term = $request->get('term'); //jQuery uses the word term
$data = Prestation::where('libelle', 'LIKE', '%'.$term.'%')
->take(10)
->get();
$results = array();
foreach ($data as $key => $value)
{
$results[] = ['id' => $value->id, 'value' => $value->libelle];
}
return response()->json($results);
}
file Js
$(document).ready(function(){
$( "#keyword" ).autocomplete({
source: '/administration',
minlenght:1,
autofocus:true,
select:function(e, ui) {
consolelog(ui);
}
});
});
I receive an answer in the console : GET http://localhost:8000/administration?term=desh 200 OK
Can you help me diagnose the problem? thank you
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1O8lk2W
via IFTTT
Aucun commentaire:
Enregistrer un commentaire