JSFiddle - React, Tailwind, and code Playground

by Matthew Dewell

HTML

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<select id="userInfo" class="ui-corner-all" Name="Title_ID">
<option value="" disabled selected>(Pay Band GS 1-15/rank)</option>
<option value="GS15 / GS15 / General Schedule 15">GS15 / GS15 / General Schedule 15</option>
<option value="GS14 / GS14 / General Schedule 14">GS14 / GS14 / General Schedule 14</option>
<option value="GS13 / GS13 / General Schedule 13">GS13 / GS13 / General Schedule 13</option>
<option value="GS12 / GS12 / General Schedule 12">GS12 / GS12 / General Schedule 12</option>
<option value="GS11 / GS11 / General Schedule 11">GS11 / GS11 / General Schedule 11</option>
<option value="GS10 / GS10 / General Schedule 10">GS10 / GS10 / General Schedule 10</option>
<option value="GS9 / GS9 / General Schedule 9">GS9 / GS9 / General Schedule 9</option>
<option value="GS8 / GS8 / General Schedule 8">GS8 / GS8 / General Schedule 8</option>
<option vlue="GS7 / GS7 / General Schedule 7">GS7 / GS7 / General Schedule 7</option>
<option value="GS6 / GS6 / General Schedule 6">GS6 / GS6 / General Schedule 6</option>
<option value="GS5 / GS5 / General Schedule 5">GS5 / GS5 / General Schedule 5</option>
<option value="GS4 / GS4 / General Schedule 4">GS4 / GS4 / General Schedule 4</option>
<option value="GS3 / GS3 / General Schedule 3">GS3 / GS3 / General Schedule 3</option>
<option value="GS2 / GS2 / General Schedule 2">GS2 / GS2 / General Schedule 2</option>
<option value="GS1 / GS1 / General Schedule 1">GS1 / GS1 / General Schedule 1</option>
<option value="CIV / CIV / Civilian">CIV / CIV / Civilian</option>
<option value="CONTR / CONTR / Contractor">CONTR / CONTR / Contractor</option>
</select>

JavaScript

(function( $ ) {

	$.widget( "custom.combobox", {
		_create: function() {

			this.wrapper = $( "<span>" )
				.addClass( "custom-combobox" )
				.insertAfter( this.element );

			this.element.hide();
			this._createAutocomplete();
			this._createShowAllButton();
		},

		_createAutocomplete: function() {
			var selected = this.element.children( ":selected" ),
				value = selected.val() ? selected.text() : "";

			this.input = $( "<input>" )
				.appendTo( this.wrapper )
				.val( value )
				.attr( "title", "" )
				.addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
				.autocomplete({
					delay: 0,
					minLength: 0,
					source: $.proxy( this, "_source" )
				})
				.tooltip({
					tooltipClass: "ui-state-highlight"
			 	});

			this._on( this.input, {
				autocompleteselect: function( event, ui ) {
					ui.item.option.selected = true;
					this._trigger( "select", event, {
						item: ui.item.option
					});
				},

				autocompletechange: "_removeIfInvalid"
			});
		},

		_createShowAllButton: function() {
			var input = this.input,
				wasOpen = false;

		  $( "<a>" )
				.attr( "tabIndex", -1 )
				.attr( "title", "Show All Items" )
				.tooltip()
				.appendTo( this.wrapper )
				.button({
					icons: {
						primary: "ui-icon-triangle-1-s"
					},
					text: false
				})
				.removeClass( "ui-corner-all" )
				.addClass( "custom-combobox-toggle ui-corner-right" )
				.mousedown(function() {
					wasOpen = input.autocomplete( "widget" ).is( ":visible" );
				})
				.click(function() {
					input.focus();

					// Close if already visible
					if ( wasOpen ) {
						return;
					}

					// Pass empty string as value to search for, displaying all results
					input.autocomplete( "search", "" );
				});
		},

		_source: function( request, response ) {
			var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
			response( this.element.children( "option" ).map(function() {
				var text = $(...