I am currently working on implementing a live search feature in Laravel 7. Everything is functioning correctly, however, I am facing an issue where I am unable to add a (href a tag) to the result list. The results are being displayed in a select option using the Select2 library without an (a) tag, which prevents them from being opened in a new page for further exploration.
This is how my blade file looks:
<div class="fre-search-wrap">
<select class="livesearch form-control" name="Find Consultants"&g t;</select>
</div>
This is the script I am using:
<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
}
});
I found the main reference for this implementation here: