Is there an event to enable/disable a select using the provided attribute : data-kt-select-disabled from javascript?
Hi Jvmvl C
Sorry for the delay. The data-kt-select-disabled attribute is only processed during component initialization. Changing it after initialization won't update the component state. Use the enable() and disable() methods for runtime control.
// Get the select element
const selectElement = document.querySelector('#my-select');
const selectInstance = KTSelect.getInstance(selectElement);
// Listen to state changes
selectElement.addEventListener('kt-select:disabled', function() {
console.log('Select disabled');
});
selectElement.addEventListener('kt-select:enabled', function() {
console.log('Select enabled');
});
// Toggle disabled state
function toggleSelect() {
if (selectInstance._config.disabled) {
selectInstance.enable();
} else {
selectInstance.disable();
}
}