I had trouble working this out. The documentation is split into Usage and API.
The load option of selectize.js is used for query/response services that will return subsets of the available data depending on the query. It makes sense that it would fire each time the query changes.
Of course, this is unnecessary if your data source does not accept query parameters. In this case, a one-time load of data should be sufficient.
According to the API, you can grab the selectize instance and call a number of methods on it, including a load.
<script>
var $select = $('#select').selectize({
valueField: 'value',
labelField: 'label',
searchField: ['label']
});
var selectize = $select[0].selectize;
selectize.load(function (callback) {
$.ajax({
url: 'http://localhost:64596/api/things',
type: 'GET',
error: function (e) {
console.error(e.responseText);
callback();
},
success: function (data) {
callback(data);
}
});
});
</script>
preload
option? – Microelectronics