How do I update more than one container/element using AHAH in Drupal?
I'm creating a summary view of products and prices, along with the ability to update the prices for each开发者_StackOverflow product (each product has 5 prices for various user roles).
I'm using AHAH to submit the specific product form, and have the form working great, including updating the old form with the new values and a message to say the jobs been done.
However, so far I can only update the one container (that which contained the submitted form) - this will mean that the view could end up with multiple success messages all over the place.
How to I get the AHAH system to update two containers - one for the form which was submitted, and one for the message (which will be a common container for all forms).
AHAH replaces the contents of the named wrapper with the 'data' value in the returned JSON response.
You could put all the items next to each other in one big wrapper, and then in your AHAH callback, call drupal_render
for each form element as they should be shown, concatenating the outputs. e.g.:
$html = drupal_render($form['item1']);
$html .= drupal_render($form['item2']);
$html .= drupal_render($form['item3']);
drupal_json(array( 'status' => TRUE, 'data' => $html ));
精彩评论