将功能绑定到Twitter Bootstrap Modal关闭 [英] Bind a function to Twitter Bootstrap Modal Close

查看:113
本文介绍了将功能绑定到Twitter Bootstrap Modal关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个新项目上使用Twitter Bootstrap lib,我希望页面的一部分刷新并检索模态关闭时的最新json数据.我看不到文档中的任何地方,有人可以向我指出或提出解决方案.

I am using the Twitter Bootstrap lib on a new project and I want for part of the page to refresh and retrieve the latest json data on modal close. I dont see this anywhere in the documentation can someone point it out to me or suggest a solution.

使用已记录方法的两个问题

Two problems with using the documented methods

 $('#my-modal').bind('hide', function () {
   // do something ...
 });

我已经在模式上附加了隐藏"类,因此它不会在页面加载时显示,因此会加载两次

I attach a "hide" class to the modal already so it does not display on page load so that would load twice

即使我删除了hide类并将元素id设置为display:none并在我点击关闭时将console.log("THE MODAL CLOSED");添加到了上面的函数中,也没有任何反应.

even if I remove the hide class and set the element id to display:none and add console.log("THE MODAL CLOSED"); to the function above when I hit close nothing happens.

推荐答案

Bootstrap 3& 4

$('#myModal').on('hidden.bs.modal', function () {
    // do something…
});

引导程序3: getbootstrap.com/javascript/#modals-events

引导程序4: getbootstrap.com/docs/4.1/components/modal/#events

$('#myModal').on('hidden', function () {
    // do something…
});

请参见 getbootstrap.com/2.3.2/javascript.html#modals →活动

这篇关于将功能绑定到Twitter Bootstrap Modal关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆