What's the sanest way to present a Ctools modal to the user while bypassing the normal AJAX workflow? For example, how could I show a completely JavaScript-generated "Are you sure you want to log out?" confirmation prompt to the user in a Ctools modal after the user clicks the "log out" link?

I know I can probably fake a box which would get the same styling as the Ctools modal, but I'd rather avoid silly hacks if not strictly necessary.

1 Answer 1


This should be possible by invoking Drupal.CTools.Modal.show directly. The function takes one argument (the modal-style), which either can be a string pointing to an object on Drupal.settings or the style-object itself.

After showing the dialog, it is possible to populate title and content using jQuery:

$('#modal-content').html('some markup here').scrollTop(0);

In your PHP code, you need to ensure that ctools modal.js and also misc/ajax.js gets loaded:



// Add your modal style to the settings. You find the defaults in modal.js near the top:
  'my-modal-style' => array(
    'modalSize' => array(
      'type' => 'fixed',
      'width' => 250,
      'height' => 250,
    'closeText' => 'Dismiss',
    'closeImage' => ...
), 'setting');
  • Turns out I'm not having a chance to implement this after all, but it'll surely be useful if I run into this problem in the future. Thanks! Commented Oct 30, 2013 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.