I am trying to catch the click event when save changes is pushed.

For some reason i can't catch the click event.

Why?

<script>
$('#inviteRequest').click(function(){
// e.preventDefault();
console.log(1);
$('#myModalInviteDestination').modal('hide');
}); </script> <!-- Modal -->
<div class="modal fade" id="myModalInviteDestination" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Enter your friends email address</h4>
</div>
<div class="modal-body">
<textarea rows="5" cols="68" name="invites"></textarea>
<div>use ; as delimiter</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="inviteRequest">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

Answers

You need to wrap this in a document.ready:

$(function() {
$('#inviteRequest').click(function(){
console.log(1);
$('#myModalInviteDestination').modal('hide');
});
});
Your element #inviteRequest does not exist at the time you try to add an event handler to it. You need to wait for the page to load first. My code is the equivalent to $(document).ready(); 

click event not triggered on bootstrap modal的更多相关文章

  1. Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上

    问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ...

  2. Bootstrap modal.js 源码分析

    /* ======================================================================== * Bootstrap: modal.js v3 ...

  3. 对bootstrap modal的简单扩展封装

    对bootstrap modal的简单扩展封装 参考自:http://www.muzilei.com/archives/677   注:原文不支持bootstrap新版本,并且居中等存在问题 此段时间 ...

  4. Bootstrap Modal 框 alert confirm loading

    /** * Created by Administrator on 2016/5/4. */ /** * 模态窗口 */ window.Modal = { tpls:{ alert:'<div ...

  5. bootstrap插件学习-bootstrap.modal.js

    bootstrap插件学习-bootstrap.modal.js 先从bootstrap.modal.js的结构看起. function($){ var Modal = function(){} // ...

  6. Bootstrap Modal 使用remote从远程加载内容

        Bootstrap的Modal这个模态窗组件还是很好用的,但在开发的过程中模态窗中的内容大部分都是从后端加载的.要实现模态窗的内容是从后端加载话,常用的实现方式有2种.它们是:     (1) ...

  7. bootstrap modal 垂直居中对齐

    bootstrap modal 垂直居中对齐   文章参考 http://www.bubuko.com/infodetail-666582.html http://v3.bootcss.com/Jav ...

  8. 在bootstrap modal 中加载百度地图的信息窗口失效解决方法

    这个问题其实很傻,解决方法没有任何技术含量,只是记录下工作中发生的事. 前阵子给一个汽车集团客户做了一个经销商查询系统,其中一个功能是使用地图标注经销商店面地址,并且实现导航功能. 页面演示地址:ht ...

  9. Bootstrap Modal 垂直方向加滚动条

    原文链接:http://blog.csdn.net/cyh1111/article/details/52960747 背景 使用Bootstrap Modal实现用户资料修改,由于用户信息过多,默认M ...

随机推荐

  1. Haproxy的安装与配置

    一.Haproxy概念 Haproxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.Haproxy特别适用于那些负载特大的web站点,这 ...

  2. mybatis自动映射和手动映射

    一对一查询 第一种方法: <!-- 查询所有订单信息 --> <select id="findOrdersList" resultType="cn.it ...

  3. Leetcode 273.整数转换英文表示

    整数转换英文表示 将非负整数转换为其对应的英文表示.可以保证给定输入小于 231 - 1 . 示例 1: 输入: 123 输出: "One Hundred Twenty Three" ...

  4. apache kafka系列之server.properties配置文件参数说明

    每个kafka broker中配置文件server.properties默认必须配置的属性如下: broker.id=0num.network.threads=2num.io.threads=8soc ...

  5. [Usaco2009 Open]工作安排Job

    Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1457  Solved: 687[Submit][Status][Discuss] Descriptio ...

  6. 【BZOJ4517】排列计数(排列组合)

    题意:1-n的一个序列,其中有m个a[i]=i,求方案数 n,m<=1000000 题意:显然ANS=c(n,m)*d[n-m] d[i]为错排方案数=d[i-1]*n+(-1)^n ; ..] ...

  7. 谈谈APP架构选型:React Native还是HBuilder

    原文链接 导读:最近公司的一款新产品APP要进行研发,老大的意思想用H5来做混合APP以达到高效敏捷开发的目的.我自然就开始进行各种技术选型的调研,这里重点想说的是我最后挑选出的2款hybrid ap ...

  8. Django学习之 - 基础视图函数

    视图:Views 获取用户请求的方法: 1: request.GET 2: request.POST 3: request.FILES # checkbox 等多选文件 4:request.POST. ...

  9. hdu 3943

    数位dp #include <cstdio> #include <cstdlib> #include <cmath> #include <stack> ...

  10. POJ 2346 【DP】

    题意: 给一个正的不大于10的偶数n,求n个数字组成的数字串前n/2位和后n/2位的和相等的个数. 思路: dp[i][j]由i位数组成的和为j的数字串的个数. dp[i][j]+=dp[i-1][j ...