我有这个字段
<div>
<input type = "text" class = "form-control" id = "driverplus" placeholder = "Fahrer">
</div>我使用的是https://www.devbridge.com/的jquery-autocomplete。
当我只是点击"driverplus“字段而没有输入任何东西来通过ajax显示整个条目列表时,我如何触发自动完成呢?
$('#driverplus').devbridgeAutocomplete({
minLength: 0,
serviceUrl: '/driverplusautocomplete',
onSelect: function (suggestion) {
alert('You selected: ' + suggestion.value + " for id " +
}
})选项minLength: 0无效,deferRequestBy: 0也无效。
发布于 2017-12-13 22:00:38
由于使用devbridge自动完成有一些障碍,我将我的框架改为http://projects.sergiodinislopes.pt/flexdatalist/。效果非常好!以防万一有人需要它,下面是解决方案:
let flexdatalist = $('#driverplus').flexdatalist({
minLength: 0,
searchIn: 'name',
selectionRequired: true,
valueProperty: '*',
searchContain:true,
data: '/driverplusautocomplete'
});控制器中的php laravel代码
public function driverplusautocomplete() {
$models = User::where('driver',1)
->orderBy('name', 'desc')
->get();
$arrtmp = array();
foreach ($models as $key => $val) {
array_push($arrtmp, $val);
}
return $arrtmp;
}https://stackoverflow.com/questions/47780429
复制相似问题