Skip to content

Instantly share code, notes, and snippets.

@mrded
Created June 12, 2014 10:56
Show Gist options
  • Save mrded/e6e9bd75d1d588ecd886 to your computer and use it in GitHub Desktop.
Save mrded/e6e9bd75d1d588ecd886 to your computer and use it in GitHub Desktop.
Drupal 7: Show ctools modal via JS.
<?php
drupal_add_js('misc/ajax.js');
ctools_add_js('modal');
ctools_add_css('modal');
// Add your modal style to the settings. You find the defaults in modal.js near the top:
drupal_add_js(array(
'my-modal-style' => array(
'modalSize' => array(
'type' => 'fixed',
'width' => 250,
'height' => 250,
),
'closeText' => 'Dismiss',
'closeImage' => ...
),
), 'setting');
Drupal.CTools.Modal.show('my-modal-style');
$('#modal-title').html('my-title');
$('#modal-content').html('some markup here').scrollTop(0);
Drupal.attachBehaviors();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment