jQuery Autocomplete order of results

前端 未结 3 2133
无人共我
无人共我 2021-02-14 08:34

I am using the jQuery-autocomplete plugin to get suggestions for completion of the input string using an AJAX call to a server. Also, the server takes care of returning the resu

3条回答
  •  生来不讨喜
    2021-02-14 09:20

    Well, it turned out to be simpler than I thought. I decided to read the code of the plugin and modify it by commenting out the code that sorts my output.

    That is when I found a variable 'sortResults:true' in defaults. So, all I needed was to set that variable to false. I didn't find this in the documentation though.

    $('#search').autocomplete ( { url: "index.php", sortResults: false } )

    Now the output is in the exact order that I require.

    I got the idea of reading the code to find/solve the problem from here : jQuery "Autocomplete" plugin is messing up the order of my data (That isn't the same plugin)

    Thanks. :)

提交回复
热议问题