无法获得简单的bootstrap模式 [英] Can not get a simple bootstrap modal to work

查看:93
本文介绍了无法获得简单的bootstrap模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个简单的bootstrap的模态样本起作用,我遵循这个文件说你可以轻松激活你页面上的模态而无需编写一行javascript。只需给一个元素一个数据控件模态属性,它对应一个模态元素id,......,但我做了什么我做的可能并且进行了大量的研究仍然无法使这个简单的模态工作。

I am trying to get a simple bootstrap's modal sample to work, I follow this document which says " You can activate modals on your page easily without having to write a single line of javascript. Just give an element a data-controls-modal attribute which corresponds to a modal element id, ...", but I have done whatever I could and had a huge amount of research still can not get this simple modal to work.

<div class="modal" id="myModal">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>

我有这样的:

<a class="btn" data-controls-modal="myModal">Launch Modal</a>

或者这个:

<a class="btn" data-toggle="modal" href="#myModal" >Launch Modal</a>

按钮激活模态,我也在页面上加载了bootstrap-modal.js。除非我添加一个javascript行来处理Launch Modal点击事件,当我点击Launch Modal时,根本没有任何事情发生,有什么我错过的吗?

button to activate the modal, I have loaded the bootstrap-modal.js on the page as well. Unless I added a javascript line to handle the "Launch Modal" click event, when I click on "Launch Modal", nothing happens at all, are there anything that I have missed?

推荐答案

我终于找到了此解决方案来自斯文并解决了这个问题。我做的是我包括bootstrap.min.js:

I finally found this solution from "Sven" and solved the problem. what I did was I included "bootstrap.min.js" with:

<script src="bootstrap.min.js"/>

而不是:

<script src="bootstrap.min.js"></script>

它解决了看起来很奇怪的问题。任何人都可以解释原因吗?

and it fixed the problem which looked really odd. can anyone explain why?

这篇关于无法获得简单的bootstrap模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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