Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1347578-ctools-close-modal-handling.patch | 507 bytes | Dave Reid |
#3 | 1347578-ctools-close-modal-handling-d6.patch | 561 bytes | Dave Reid |
#2 | 1347578-ctools-close-modal-handling.patch | 498 bytes | Dave Reid |
#2 | 1347578-ctools-close-modal-handling-d6.patch | 561 bytes | Dave Reid |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedHm. 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:
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.
Comment #2
Dave ReidCool. This works as expected. Here's a patch against 7.x-1.x and 6.x-1.x.
Comment #3
Dave ReidMissed the context parameter in the D7 patch.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to both branches. Thanks for turning this into a patch!