Closed
Description
So I see a lot of threads related to this issue.
Here is what I did for a fix until it gets patched:
With PHP, I am adding a json object of the items I want to pass in via the values data param:
<input name="redirect_parameter_model" class="bigdrop col-md-12 no-padding selectized" data-values="[{"id":"203","value":"Joypad C102"},{"id":"203","value":"Joypad C74"}]" value="" tabindex="-1" placeholder="Select a Model">
Within the selectize object I use the onintialise method
onInitialize: function() {
var objects = [];
$.each(elem.data('values'), function (i, b) {
objects[b.value] = { id: b.id, model: b.value };
});
v.selectize.preLoad(objects);
}
Note, model is my valueField, labelField and searchField.
As I am looping and creating the object, I then pass over to a custom method that I created called preLoad. Which I placed under "refreshOptions".
preLoad: function(data) {
var self = this;
// Add options to be able to insert the items
this.options = data;
// Add items
Object.keys(data).forEach(function(key) {
self.addOption(key);
self.addItem(key);
});
// Clear Options
self.options = self.sifter.items = {};
},
Now I get items added in with no problems on init of the control 👍
Hopefully this gets added / or used for better functionality in the base :)