There are two(or more) selectize dropdown where dropdown values (option values) are created by user. The issue is that two selectize should have same dropdown values when user creates some values in either of the two selectize dropdown. The dropdown values should be same and loads in other dropdown values irrespective of where they created(added).
Ref Link:- https://selectize.github.io/selectize.js/
Fiddle Link:- http://jsfiddle.net/1oy2d6e9/
html
<section class="demo" id="demo-single-item-select">
<div class="header">
Single Item Select
</div>
<div class="sandbox">
<label for="select-beast">Beast:</label>
<select id="select-beast" class="demo-default" placeholder="create a person by typing...">
</select>
</div>
<div class="sandbox">
<label for="select-beast">Beast2:</label>
<select id="select-beast2" class="demo-default" placeholder="create a person by typing...">
</select>
</div>
<div class="description">
These two select box have same values when values are created in either of the two.
<a href="https://selectize.github.io/selectize.js/">https://selectize.github.io/selectize.js/</a>
</div>
</section>
js
var gArr = [];
// selectize should load all dropdown values ie in gArr initially;
$('#select-beast2').selectize({
create: true,
sortField: 'text',
searchField: 'item',
create: function(input) {
gArr.push(input); //<=======storing in global variable
return {
value: input,
text: input
}
}
});
$('#select-beast').selectize({
create: true,
sortField: 'text',
searchField: 'item',
create: function(input) {
gArr.push(input); //<=======storing in global variable
return {
value: input,
text: input
}
}
});