JSFiddle - React, Tailwind, and code Playground

by B L Praveen

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css">
<input type="text" id="school" />
<div id="debug"></div>

JavaScript

$(document).ready(function() {
    var schools = [
        {
        "label": "Boston University",
        "value": "Boston University",
        "nickname": "BU"},
    {
        "label": "Some extra element",
        "value": "Value of second",
        "nickname": "2nd"}
    ];

    function custom_source(request, response) {
        var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
        response($.grep(schools, function(value) {
            return matcher.test(value.value)
                || matcher.test(value.nickname);
        }));
    }

    $("#school").autocomplete({
        source: custom_source,
        minLength: 0,
        select: function(event, ui) {
            // your code
        }
    });
});