Ajax callback of select form field not triggered when changed by javascript, only when changed manually I have a simple ajax form with select form input:

$form['children']['number_children'] = array(
  '#title' =&gt; t('Počet detí'),
  '#type' =&gt; 'select',
  '#options' =&gt; range(0, 15),
  '#default_value' =&gt; $number_children,
  '#ajax' =&gt; array(
    'callback' =&gt; 'ajax_callback_registration_children',
    'wrapper' =&gt; 'children-div',
    'method' =&gt; 'replace',
    'effect' =&gt; 'fade',
  ),
);


When the select input is changed manually it properly executes an ajax and appends new inputs into the form. But I need to trigger the ajax callback by javasrcipt code that is changing the selected option:

$('#children-div select[name="number_children"]').val('3').change();


This changes the value, but the ajax is not triggered at all. Why is it not working and is there something I could do?



EDIT: It works when this command: $('#children-div select[name="number_children"]').val('3').change(); or another way of triggering an event is typed in browser console, but not if the same code is executed from my chrome extension. Is it possible that Drupal somehow verifies what exactly triggered the event?
try to specify the event, like 

$form['children']['number_children'] = array(
  '#title' =&gt; t('Počet detí'),
  '#type' =&gt; 'select',
  '#options' =&gt; range(0, 15),
  '#default_value' =&gt; $number_children,
  '#ajax' =&gt; array(
    'callback' =&gt; 'ajax_callback_registration_children',
    'wrapper' =&gt; 'children-div',
    'method' =&gt; 'replace',
    'effect' =&gt; 'fade',
    'event' =&gt; 'change',
  ),
);


this should be sufficent .. (but select uses change already as default event ..)

other things to try could be

add a custom event, like:

'event' =&gt; 'custom_change',

jQuery('select').trigger('custom_change');


See How to trigger Ajax forms machinery

or invoke the callback yourself:

Drupal.ajax['#ID'].eventResponse('#ID');