I'm trying to make a module to load a text in the modal window

The code I use:


function general_menu() { 
  $items = array();
  $items['catalog-test'] = array(
    'title' => 'Ajax Test',
    'page callback' => 'example_test_main',
    'access arguments' => array('access content'),
  );
  $items['catalog-test/%ctools_js/go'] = array(
    'page callback' => 'example_test_ajax_callback',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
  );   
  
  return $items;
}

function example_test_main() {
  ctools_include('modal');
  ctools_modal_add_js();
  $output = l('Load content', 'catalog-test/nojs/go', array(
    'attributes' => array('class' => 'ctools-use-modal ctools-modal-ctools-sample-style')));
    $sample_style = array(
    'ctools-sample-style' => array(
      'modalSize' => array(
        'type' => 'scale',
        'width' => .8,
        'height' => .8,
        'addWidth' => 20,
        'addHeight' => 15,
      ),
      'modalOptions' => array(
        'opacity' => .5,
        'background-color' => '#000',
      ),
      'animation' => 'fadeIn',
      'modalTheme' => 'CToolsGeneralModal',
      'throbber' => theme('image', ctools_image_path('ajax-loader.gif', 'general', 'ctools-theme/images'), t('Loading...'), t('Loading')),
    ),
  );

  drupal_add_js($sample_style, 'setting');
  ctools_add_js('ctools-ajax-sample', 'general', 'ctools-theme/js');
  ctools_add_css('ctools-ajax-sample', 'general', 'ctools-theme/css');		
  return $output;
}

function example_test_ajax_callback($js = FALSE) {
  $output = 'Some content here';
  $title = 'Modal example';
  if ($js) {
    ctools_include('ajax');
    ctools_include('modal');
    ctools_modal_render($title, $output);
  }
  else {
    drupal_set_title($title);
    return $output;
  }	
}

All works fine, BUT when js files are aggregated the window opens only once. After I close it, second click just redirecting me to the "..../nojs/go" path.

screencast

Any ideas how to fix it?

Comments

volocuga’s picture

rjbrown99’s picture

Not sure how core js aggregation works, but I'm really digging http://drupal.org/project/advagg. You may want to check it out as it has a different method of aggregating the javascript files.

japerry’s picture

Status: Active » Closed (outdated)

Closing this issue as outdated as Drupal 6 ctools is not supported. If this issue is relevant for Drupal 7, feel free to re-open and mark for Drupal 7 (or 8)