I have a form with a radio buttons (inside div#edit-field-nomination-und). I need to call a following AJAX callback:
function _onfit_ajax_get_term_description_callback($term) {
return array(
'#type' => 'ajax',
'#commands' => array(
ajax_command_html('#nomination-desc', $term->description)));
}
function onfit_menu() {
// ...
$items['ajax/onfit/taxonomy/term/%taxonomy_term/description'] = array(
'title' => 'Get taxonomy term description by AJAX',
'page callback' => '_onfit_ajax_get_term_description_callback',
'page arguments' => array(4),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'delivery callback' => 'ajax_deliver',
);
return $items;
}
Here is an attachment code (I dislike it and I want to use #ajax['path']):
Drupal.behaviors.onfitExampleBehavior = {
attach : function(context, settings) {
$('#edit-field-nomination-und input', context)
.once('edit-field-nomination-und', function() {
var url = '/ajax/onfit/taxonomy/term/' + $(this).val() + '/description'
new Drupal.ajax('nomination-desc-wrapper', $(this), { url: url, event: 'change' });
});
}
};
Is it possible to attach AJAX callback to a radio buttons by the means of hook_form_alter? I don't want to use #ajax['callback'], because the entire form will be send during each AJAX call. I think #ajax['path'] must be a more lightweighted. But the problem is that I don't understand how to pass a selected radio item id to a #ajax['path'].