Frequently I add a 'Cancel' link from inside $form['actions'] in forms that appear in the modal. I would really like when clicking those links to just close the modal, just like the top-right 'Close window'. I've tried giving them a .close class but this also gives the link a white color via CSS which for most admin themes make the link invisible.

Comments

Hm. It looks like the click behavior is bound when the frame is rendered, not when the content is rendered. It looks like it would be easy enough to add a standard modal close class, though.

From javascript, I believe your code would look something like this in a behavior:

$('.ctools-close-modal:not(.ctools-close-modal-processed)')
  .addClass('ctools-close-modal-processed')
  .click(function() {
    Drupal.CTools.Modal.dismiss();
    return false;
  });

We could put that (or a working version in case I've typo'd something) in the modal's behavior and then in theory anyone could use it, but something like that could also go in any module's behavior to bind to a button specifically.

Status:Active» Needs review
StatusFileSize
new561 bytes
new498 bytes

Cool. This works as expected. Here's a patch against 7.x-1.x and 6.x-1.x.

Missed the context parameter in the D7 patch.

Status:Needs review» Fixed

Committed to both branches. Thanks for turning this into a patch!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.