问题可能是 - “我怎样才能触发一个更新了双重回调参数的 js 函数”
这就是我所做的:
我的表格是这样的:
$form['letterdrop_id'] = array(
'#type' => 'select',
'#title' => 'Letterdrops',
'#options' => $letterdrops,
'#prefix' => '<div id="replace_div_ld">',
'#suffix' => '</div>',
'#ajax' => array(
'callback' => 'agc_ems_form_map_change',
),
);
使用此回调函数:
function agc_ems_form_map_change($form, &$fstate) {
return array(
'#type' => 'ajax',
'#commands' => array(
// this command is to reload a form element
ajax_command_replace("#agc_map", render($form['map'])),
// this command does the business and calls my custom function,
// with a parameter object supplied
array('command' => 'afterAjaxCallbackExample',
'selectedValue' => 'i am not a fish',
)
));
}
这是我的js函数
(function($, Drupal) {
// put function into drupal commands:
Drupal.ajax.prototype.commands.afterAjaxCallbackExample =
function(ajax, response, status) {
// response object as passed in our Ajax callback
// do what you want in here
alert(response.selectedValue);
};
}(jQuery, Drupal));
100% 归功于 jaypan