Skip to content

JQuery autocomplete in Laravel

I want to add autocomplete JQuery in my Laravel project, I found a lot of solutions, but this solution helped me, it is very simple and nice javascript code.

$(function () {
$( "#q" ) . autocomplete({
source: "search/autocomplete",
minLength: 3,
select: function (event, ui) {
$('#q') . val(ui . item . value);
}
});
});

You can find full code from the below link:

https://gist.github.com/imranismail/10200241

After I add this code in my project, nothing occurred and I did not saw autocomplete.

I found, there is a problem in style because everything else worked well.

I searched again about this problem and I saw this code for fix problem

.ui-autocomplete {
    position: absolute;
    top: 0;
    left: 0;
    cursor: default;
    background-color:#fff;
    border: 1px solid #aaaaaa;
    max-height: 200px;

    overflow-y: auto;   /* prevent horizontal scrollbar */
    overflow-x: hidden; /* add padding to account for vertical scrollbar */
    z-index:1000 !important;
}
Source:  https://stackoverflow.com/questions/32250544/jquery-ui-autocomplete-is-not-styled-correctly

If you have a similar experience, please share it with me.

Published inprogramming challenge

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *