I got a custom ajax callback which replaces my checkbox options based on the select option.
Now after the checkboxlist get's updated i need to execute a jquery function on those checkboxes.
How can i execute this custom jquery function after the callback is done, so after the checkboxlist is updated.
Form element:
$widget['select_box'] = array(
'#type' => 'select',
'#title' => 'Select bussen',
'#options' => $options,
'#validated' => TRUE,
'#default_value' => '_none',
'#attributes' => array('class' => array('select-province')),
//The callback
'#ajax' => array(
'callback' => 'ajax_select_callback',
// 'wrapper' is the HTML id of the page element that will be replaced.
'wrapper' => 'replace_select_div',
),
);
//Form element wich get updated
$widget['select_box_2'] = array(
'#type' => 'checkboxes',
'#title' => 'Select bussen',
'#options' => ...,
'#prefix' => '<div id="replace_select_div">',
'#suffix' => '</div>',
);
Ajax callback function:
function ajax_select_callback($form, $form_state) {
// The form has already been submitted and updated. We can return the replaced
// item as it is.
return $form['line_item_fields']['field_bussen_select']['und'][0]['select_box_2']
}
Jquery function i run on the checkboxes:
jQuery("input[type='checkbox']").change(function () {
jQuery(this).parent().siblings('ul')
.find("input[type='checkbox']")
.prop('checked', this.checked);
});