How to add comment to a node with ajax (ctools modal)? I' trying to create custom module that should add comment to a content type in a modal window, with ajax. I wrote following code, but when I click on the 'Add review' link, browser loads new page when I can add 'reviews about shop' content type. I want to do this in a modal window, without reloading

function current_posts_menu() {
 $items['add/%ctools_js/review'] = array(
   'page callback'    =&gt; 'current_posts_ctools_modal_review',
   'page arguments'   =&gt; array(1),
   'access arguments' =&gt; array('create review content'),
 );
 return $items;
}

function current_posts_popup_style() {

  static $added = FALSE;
  if ($added == FALSE) {
    $added = TRUE;

    // Include the CTools tools that we need.
    ctools_include('modal');
    ctools_include('ajax');
    ctools_modal_add_js();


    $popup_style = array(
      'first-popup-style' =&gt; array(
        'modalSize' =&gt; array(
          'type' =&gt; 'fixed', 
          'width' =&gt; 420,  
          'height' =&gt; 'auto', 
        ),
        'modalOptions' =&gt; array(
          'opacity' =&gt; (float) 0.3, .
          'background-color' =&gt; '#000000', 
        ),
        'closeText' =&gt; '', 
        'loadingText' =&gt; '', .
        'animation' =&gt; 'fadeIn', 
        'animationSpeed' =&gt; 'fast', 
      ),
    );


    drupal_add_js($popup_style, 'setting');

  }
}
function current_posts_block_info(){
 $blocks['add_review'] = array(
   'info' =&gt; t('Add review'),
 );
 return $blocks;
}

/**
* Implements hook_block_view().
*/
function current_posts_block_view($delta = '') {
    $block = array();
 switch ($delta) {
   case 'add_review':
     ctools_include('ajax');
     ctools_include('modal');
     ctools_modal_add_js();
     current_posts_popup_style();
     $comment_site_id = arg(1);
      $block['content'] = l(t('Add a review'), "add/nojs/review/{$comment_site_id }", array('html' =&gt; TRUE, 'attributes' =&gt; array('class' =&gt; "ctools-use-modal ctools-modal-first-popup-style")));
/*ctools-modal-first-popup-style */
     break;
 }
 return $block;
}

function current_posts_form_alter(&amp;$form, &amp;$form_state, $form_id) {
 switch ($form_id) {
   case 'comment_site':
     $comment_site_id = arg(3);
     if (is_numeric(arg(3))) {
       $lang = field_language('node', $form['#node'], 'field_news');
       // Declaration the default value for field on the comment creating form.
       $form['field_news'][$lang][0]['nid']['#default_value'] = $comment_site_id;

     }

 }
}

function current_posts_ctools_modal_review($js = FALSE) {
 // loading libraries ctools'a
 ctools_include('node.pages', 'node', '');
 ctools_include('modal');
 ctools_include('ajax');

 $type = 'reviews_about_shop';
 $node = (object) array(
   'uid' =&gt; $user-&gt;uid,
   'name' =&gt; (isset($user-&gt;name) ? $user-&gt;name : ''),
   'type' =&gt; $type,
   'language' =&gt; LANGUAGE_NONE
   );
  // Loading node form with disabled scripts.
 if (!$js) {
   return drupal_get_form($type . '_node_form', $node);
}
 // Create array $form_state.
 $form_state = array(
   'title' =&gt; t('Add Review'),
   'ajax'  =&gt; TRUE,
 );

    $form_state['build_info']['args'] = array($node);
    $output = ctools_modal_form_wrapper($type . '_node_form', $form_state);
    // Actions after form submit.
    if (!empty($form_state['executed'])) {
    $output = array();
    // Close pop up.
    $output[] = ctools_modal_command_dismiss();
    $comment_site_id = arg(3);
    // Insert  updated  view into a  page.
    if (is_numeric(arg(3))) {
     $output[] = ajax_command_html('.latest-reviews-full-style', views_embed_view('reviews_on_main_page', 'block', arg(3)));
    }
 }
    print ajax_render($output);
}


Note: I need like adding content type in a modal window. In my module reviews_about_shop is a content type that linked to a content type comment_site.
You need to add ajax library to that

drupal_add_library('system', 'drupal.ajax');


Or you can use the below function to render the ajax link 

$block['content'] = l(t('Add a review'), "add/nojs/review/{$comment_site_id }", array('html' =&gt; TRUE, 'attributes' =&gt; array('class' =&gt; "ctools-use-modal ctools-modal-first-popup-style")));


Replace the above line to below.

$block['content'] = ctools_modal_text_button(t('Newsletter datacapture modal'), "add/nojs/review/{$comment_site_id }", t('Add a review'), "ctools-modal-first-popup-style");


Modify the argument 

function current_posts_menu() {
 $items['add/%ctools_js/review/%'] = array(
   'page callback'    =&gt; 'current_posts_ctools_modal_review',
   'page arguments'   =&gt; array(1,3),
   'access arguments' =&gt; array('create review content'),
 );
 return $items;
}


and not to mention "Clear Cache"