function better_comments_preview_cancel in Better Comments 7.2
Same name and namespace in other branches
- 7 better_comments.module \better_comments_preview_cancel()
Cancel the previews of the comment.
1 string reference to 'better_comments_preview_cancel'
- better_comments_menu in ./better_comments.module 
- Implements hook_menu().
File
- ./better_comments.module, line 413 
- Better Comments provides option to configure the comment system.
Code
function better_comments_preview_cancel($nid, $cid) {
  // Add a new form and not from cached.
  if ($cid) {
    $comment = comment_load($cid);
    $node = node_load($comment->nid);
    $comment = comment_view($comment, $node);
    $form = trim(drupal_render($comment));
    $commands[] = ajax_command_replace('#comment-wrap-' . $cid, $form);
  }
  else {
    $node = node_load($nid);
    $form_build = drupal_get_form("comment_node_{$node->type}_form", (object) array(
      'nid' => $nid,
    ));
    $form = drupal_render($form_build);
    $commands[] = ajax_command_replace('.comment-form', $form);
  }
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}