2

Given this code that creates and opens a ctools modal in a Drupal 6 site:

var content = 'my content';
var title = 'my title';
Drupal.CTools.Modal.show();
$('#modal-title').html(title);
$('#modal-content').html(content);
Drupal.attachBehaviors(); 

How do I add a link in content that will close the modal?

Didn't work:

  • Adding a link with class "close". This is how the right corner close link that ctools automatically adds to the modal works
  • Using onclick="Drupal.CTools.Modal.show();"
  • Using onclick="Drupal.CTools.Modal.close();"

Any ideas what I might be doing wrong?

Kara
  • 6,115
  • 16
  • 50
  • 57
Justin
  • 2,914
  • 5
  • 41
  • 66

2 Answers2

6

Try onclick="Drupal.CTools.Modal.dismiss()" instead of .close().

Alexander
  • 2,052
  • 1
  • 15
  • 17
0

Based on Alexander answer, here you have another approach when you click out, the modal is dismiss.

$('#modalBackdrop').live("click", function(){ Drupal.CTools.Modal.dismiss(); });
Israel Morales
  • 1,681
  • 1
  • 14
  • 6