成功Ajax之后如何触发Drupal.attachBehaviors
我有一个模块,当单击链接时,该模块通过ajax更新节点。 该链接是一个切换,它应在第一次单击时将节点更新为值1,然后在随后的单击中将节点更新为0,以此类推。就像打开/关闭某些内容一样。 下面的代码在页面加载后的第一次点击上有效,但在随后的点击上无效。我相信每次单击后都必须调用/触发Drupal.attachBehaviors,但是我不知道该怎么做。 模块 function mymodule_menu() { $items['mypath/%/%/ajax'] = array( 'title' => 'My title', 'page callback' => 'mymodule_ajax_callback', 'page arguments' => array(1,2), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); ... } function mymodule_ajax_callback($id, $status) { //Validation[...] //Node Update using $id as the nid and $status as the field …