I've tried all options to trigger an ajax event on change of a selectbox option inside form alter hook, but nothing works. Below is the sample code
$form['field_select_box']['#ajax'] =
[
'callback' => 'toggleOptions',
'event' => 'change',
'wrapper' => 'edit-field-target'
];
If I just try to attach the ajax event to a simple text field (like title), it WORKS.
$form['title']['widget'][0]['value']['#ajax'] =
[
'callback' => 'updateSubdomain',
'disable-refocus' => FALSE,
'event' => 'change',
'wrapper' => 'edit-field-subdomain-0-value',
];
Help is appreciated