开发者

How do you close a manually created and opened ctools modal in Drupal 6?

开发者 https://www.devze.com 2023-03-19 09:27 出处:网络
Given this code that creates and opens a ctools modal in a Drupal 6 site: var content = \'my content\';

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 m开发者_如何学Pythonodal works
  • Using onclick="Drupal.CTools.Modal.show();"
  • Using onclick="Drupal.CTools.Modal.close();"

Any ideas what I might be doing wrong?


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


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(); });
0

精彩评论

暂无评论...
验证码 换一张
取 消