Change Listener

Listen for 'change' events on the original input/select and update Tom Select accordingly

var input = document.getElementById('input-change');
new TomSelect(input,{
	plugins: ['change_listener'],
});
document.getElementById('change-input').addEventListener('click',function(evt){
	evt.preventDefault();
	evt.stopPropagation();

	input.value = 'new value';
	var evt = document.createEvent('HTMLEvents');
	evt.initEvent('change', false, true);
	input.dispatchEvent(evt);
});
<input type="text" id="input-change" value="original value" autocomplete="off">
<button type="button" class="btn btn-sm btn-success" id="change-input">Change original input</button>

Plugin Configuration

No additional configuration settings for this plugin

Available Plugins