javascript - How do you close a manually created and opened ctools modal in Drupal 6? - Stack Overflow

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 modal works
  • Using onclick="Drupal.CTools.Modal.show();"
  • Using onclick="Drupal.CTools.Modal.close();"

Any ideas what I might be doing wrong?

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?

Share Improve this question edited Mar 20, 2015 at 0:03 Kara 6,22616 gold badges53 silver badges58 bronze badges asked Jul 8, 2011 at 16:18 JustinJustin 2,9346 gold badges41 silver badges66 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745185051a4615596.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信