I'm using typeahead for an autocomplete field. When i use option remote like explaint here: https://blog.twitter.com/2013/twitter-typeaheadjs-you-autocomplete-me It show all entries and not the subset it should show. Here is the js code:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#palettenNummerEinlagerung').typeahead({
name: 'nummer',
remote:'http://ift.tt/1R5cgso'
});
});
</script>
And the serverside action for the json wich should be recived remotely:
public function getPalettennummerEingelagert(){
$result=\DB::table('paletten')
->leftJoin('einlagerungen', function ($join) {
$join->on('paletten.id', '=', 'einlagerungen.palette_id');
})
->whereNotNull('einlagerungen.palette_id')
->whereNull('einlagerungen.entahmedatum')
->where('nummer', 'LIKE', '%'.\Input::get('q').'%')
->select('nummer')
->get();
$returnArr=array();
for ($i=0;$i<count($result);$i++)
{
$returnArr[]=''.$result[$i]->nummer.'';
}
return json_encode($returnArr);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire