live搜索添加一个href的结果



我在laravel 7中有一个实时搜索一切正常但我不能添加(标签)的结果列表因为结果显示在没有(a)标记的选择选项(select2库)中,并且不能在新页面中打开以查看该关键字的结果

我的刀片:

<div class="fre-search-wrap">
<select class="livesearch form-control" name="Find Consultants"></select>
</div>
我scripst

:

<script type="text/javascript">
$('.livesearch').select2({
placeholder: 'Select Consultants',
ajax: {
url: '/live_search/action',
dataType: 'json',
delay: 550,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.title,
id: item.id
}
})
};
},
cache: true
}
});

的主要来源是这个https://www.positronx.io/laravel-autocomplete-search-with-select2-example/

你好,你可以用这个来添加一个标签:


$('.livesearch').select2({
placeholder: 'Select Consultants',
ajax: {
url: '/live_search/action',
dataType: 'json',
delay: 550,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: ""+item.title+"", // a tag
id: item.id
}
})
};
},
cache: true
}
});

最新更新