问题描述
我正在尝试让一个简单的引导程序的模态样本工作,我遵循 this document 其中说您可以轻松地在页面上激活模态,而无需编写一行 javascript.只需给一个元素一个 data-controls-modal 属性,该属性对应于一个模态元素 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?
推荐答案
我终于找到了这个解决方案来自Sven"并解决了这个问题.我所做的是将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?
这篇关于无法让简单的引导模式工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!