jQuery, I need to programmatically click / select Form items (radios, select lists, checkboxes, etc). This field item has an
'#ajax' action / callback defined using Form API.
The following code from a similar question works for submit buttons (Programatically trigger a click on an AJAX enabled form submit button):
However, this does not work for radio buttons. I have also tried creating a copy of the element and making my own AJAX call using the following code from another similar question (Use Drupal7 AJAX goodness programmatically):
base = 'edit-my-radio-button'; element = '<input type="radio" id="'+base+'" name="cat-selector" value="garfield" class="form-radio ajax-processed">'; element_settings = Drupal.ajax[base].element_settings; myAjax = new Drupal.ajax(base, element, element_settings); myAjax.eventResponse(element, 'click');
The AJAX call is made, but the screen does not update as if the user clicked it. How can I programmatically select a radio button or select list using
jQuery and cause Drupal to execute the AJAX call?
Please note: I have purposely kept this question as open ended as possible. My hope is that there is a more general way to do this for all form element types and that future answers regarding these can be considered relevant so that we have a single resource for this problem.