click event not triggered on bootstrap modal
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">×</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的更多相关文章
- Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上
问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ...
- Bootstrap modal.js 源码分析
/* ======================================================================== * Bootstrap: modal.js v3 ...
- 对bootstrap modal的简单扩展封装
对bootstrap modal的简单扩展封装 参考自:http://www.muzilei.com/archives/677 注:原文不支持bootstrap新版本,并且居中等存在问题 此段时间 ...
- Bootstrap Modal 框 alert confirm loading
/** * Created by Administrator on 2016/5/4. */ /** * 模态窗口 */ window.Modal = { tpls:{ alert:'<div ...
- bootstrap插件学习-bootstrap.modal.js
bootstrap插件学习-bootstrap.modal.js 先从bootstrap.modal.js的结构看起. function($){ var Modal = function(){} // ...
- Bootstrap Modal 使用remote从远程加载内容
Bootstrap的Modal这个模态窗组件还是很好用的,但在开发的过程中模态窗中的内容大部分都是从后端加载的.要实现模态窗的内容是从后端加载话,常用的实现方式有2种.它们是: (1) ...
- bootstrap modal 垂直居中对齐
bootstrap modal 垂直居中对齐 文章参考 http://www.bubuko.com/infodetail-666582.html http://v3.bootcss.com/Jav ...
- 在bootstrap modal 中加载百度地图的信息窗口失效解决方法
这个问题其实很傻,解决方法没有任何技术含量,只是记录下工作中发生的事. 前阵子给一个汽车集团客户做了一个经销商查询系统,其中一个功能是使用地图标注经销商店面地址,并且实现导航功能. 页面演示地址:ht ...
- Bootstrap Modal 垂直方向加滚动条
原文链接:http://blog.csdn.net/cyh1111/article/details/52960747 背景 使用Bootstrap Modal实现用户资料修改,由于用户信息过多,默认M ...
随机推荐
- Django reverse函数
1.总urls.py内容如下: from django.contrib import admin from django.urls import path from django.conf.urls ...
- SpringMVC中controller的跳转
controller中的重定向 (1)不需要传递参数重定向 方式一:使用ModelAndView return new ModelAndView("redirect:/toLi ...
- jquery中的全选,全不选
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 69. JPA实体Bean的生命周期【从零开始学Spring Boot】
[从零开始学习Spirng Boot-常见异常汇总] 在使用JPA的时候,如果对bean的生命周期不了解的话,难免会碰到一些问题,比如:InvalidDataAccessApiUsageExcepti ...
- 登录页面练习servlet
登录练习: 1创建登录页面 创建servlet进行登录页面请求 2点击登录完成操作 浏览器发送请求到服务器(用户信息+其他数据 )3服务器调用对应的servlet进行处理 设置响应编码格式 获取请求信 ...
- 解决安装oracle11g r2时提示pdksh conflicts with ksh-20100621-2.el6.i686问题
http://blog.csdn.net/linghao00/article/details/7943740 http://www.2cto.com/os/201306/218566.html 在Ce ...
- c++之虚基类初始化
C++虚基类构造函数下面文章详细介绍C++虚基,所谓C++虚基类:是由最派生类的构造函数通过调用虚基类的构造函数进行初始化的,但前提是要深入理解到底什么是C++虚基类,及他是怎么运行的. 前面讲过,为 ...
- [正在学习开发板]分享--- iTOP-4412移植CAN
首先拷贝迅为提供的 libcanjni.tar.gz 压缩包到 android 源代码的"iTop4412_ICS/device/samsung/common"文件夹以下,然后使用 ...
- Office EXCEL 创建图片超链接打不开怎么办 Excel打开图片提示发生了意外错误怎么办
如下图所示,点击超链接提示无法打开指定的文件 如果使用Office打开,则提示发生了意外错误 你需要先把IE浏览器打开,这样就可以打开了,并非是图像的相对位置不正确导致的.
- Android 项目导入常见错误
1.SDK版本号不正确应,你能够打开你项目中的project.properties文件,改动target=android-18(我这是18) ,将18改 为14(其它都能够),再改回18会又一次载入. ...