So here's what I'm trying to do:
1. I create and render the following form element:
$form['rb_download_' . $doc_id] = array(
'#type' => 'submit',
'#name' => 'doc_' . $doc_id,
'#prefix' => "<div id='rb_doc_order_{$doc_id}'>",
'#suffix' => '</div>',
'#value' =>variable_get('rb_order_button', "buyOnline"),
'#ahah' => array(
'event' => 'click',
'path' => "rb/case/doc_order_js/$case->nid/$doc_id",
'wrapper' => "rb_doc_order_{$doc_id}",
'effect' => 'fade',),
);
2. The action function returns and replaces the element above with a new element:
function rb_case_doc_order_js($case, $doc_id) {
$button['rb_download_' . $doc_id] = array(
'#type' => 'submit',
'#name' => 'doc_' . $doc_id,
'#prefix' => "<div id='rb_doc_order_{$doc_id}'>",
'#suffix' => '</div>',
'#value' => variable_get('rb_order_confirm', "Remove from cart"),
//'#attributes' => array('class' => 'ahah-processed'),
'#ahah' => array(
'event' => 'click',
'path' => "rb/case/doc_unorder_js/$case->nid/$doc_id",
'wrapper' => "rb_doc_order_{$doc_id}",
'effect' => 'fade',),
);
$output .= drupal_render($button);
$output .= "<script type='text/javascript'>\n";
$output .= "cart_block_item_count($count);\n";
$output .= "Drupal.ahah;\n";
$output .= "</script>\n";
print drupal_json($output);
}
3. The results are that the old button is replaced by the one above, but the new button is not AJAX
enabled.
What do I need to do to make the new returned element AHAH
ready?