JSFiddle - React, Tailwind, and code Playground

by Leon Alvarez Del Canto

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/css/selectize.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/js/selectize.js"></script>
<link rel="stylesheet" href=" https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
 <body>
		<div id="wrapper">
			<h1>Selectize.js</h1>
			<div class="demo">
				<h2>State / City Selection</h2>
				<p>A demonstration showing how to use the API to cascade controls for a classic state / city selector.</p>
				<p><strong>Note:</strong> The API for fetching cities is a little spotty, so if it fails to list cities, that's the problem.</p>
				<div class="control-group">
					<label for="select-beast">State:</label>
					<select id="select-state" placeholder="Pick a state...">
						<option value="">Select a state...</option>
						<option value="1">Alfa Roeo<option>
						<option value="2">Audi<option>
						<option value="3">Benley</option>
						
					</select>
					<label for="select-beast" style="margin-top:20px">City:</label>
					<select id="select-city" placeholder="Pick a city..."></select>
				</div>

CSS

.selectize-control::before {
			-moz-transition: opacity 0.2s;
			-webkit-transition: opacity 0.2s;
			transition: opacity 0.2s;
			content: ' ';
			z-index: 2;
			position: absolute;
			display: block;
			top: 12px;
			right: 34px;
			width: 16px;
			height: 16px;
			background: url(images/spinner.gif);
			background-size: 16px 16px;
			opacity: 0;
		}
		.selectize-control.loading::before {
			opacity: 0.4;
		}

JavaScript

var xhr;
				var select_state, $select_state;
				var select_city, $select_city;
				$select_state = $('#select-state').selectize({
					onChange: function(value) {
						if (!value.length) return;
						select_city.disable();
						select_city.clearOptions();
						select_city.load(function(callback) {
							xhr && xhr.abort();
							xhr = $.ajax({
								url: 'http://http://gps-amstaff1.c9users.io/make/'+ value +,
								success: function(results) {
									select_city.enable();
									callback(results);
								},
								error: function() {
									callback();
								}
							})
						});
					}
				});
				$select_city = $('#select-city').selectize({
					valueField: 'name',
					labelField: 'name',
					searchField: ['name']
				});
				select_city  = $select_city[0].selectize;
				select_state = $select_state[0].selectize;
				select_city.disable();