i am using bootstrap modal in my asp.net project and my code is
我在我的asp.net项目中使用bootstrap模式,我的代码是
<div id="mymodal" class="modal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a id ="closemodal" href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
and my javascript in my master page is
我的主页中的javascript是
<script type="text/javascript">
$(function () {
$('#closemodal').click(function () {
$('#mymodal').modal('hide');
});
});
</script>
but the modal doesn't closes when i click close button in firebug, error is shown with the java-script writing it's not a function
但是当我点击firebug中的关闭按钮时,模态没有关闭,错误显示在java脚本中,它写的不是函数
1 个解决方案
#1
2
The point of bootstrap is that you shouldn't need that jQuery to get it to work. You can delete that javascript and just add an attribute to your close button and it should work: (it is the data-dismiss="modal" that closes the modal popup.)
引导程序的一点是你不应该让jQuery让它工作。您可以删除该javascript,只需在关闭按钮中添加一个属性,它应该可以工作:(关闭模态弹出窗口的是data-dismiss =“modal”。)
<div id="mymodal" class="modal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a id="closemodal" href="#" class="btn" data-dismiss="modal" aria-hidden="true">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
You need the bootstrap javascript file included in your master page, which I assume must already be there if you have a modal popup that is popping up as normal.
你需要你的母版页中包含的bootstrap javascript文件,如果你有一个正常弹出的模态弹出窗口,我认为它必须已经存在。
<script language="JavaScript" type="text/javascript" src="bootstrap.min.js"></script>
#1
2
The point of bootstrap is that you shouldn't need that jQuery to get it to work. You can delete that javascript and just add an attribute to your close button and it should work: (it is the data-dismiss="modal" that closes the modal popup.)
引导程序的一点是你不应该让jQuery让它工作。您可以删除该javascript,只需在关闭按钮中添加一个属性,它应该可以工作:(关闭模态弹出窗口的是data-dismiss =“modal”。)
<div id="mymodal" class="modal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a id="closemodal" href="#" class="btn" data-dismiss="modal" aria-hidden="true">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
You need the bootstrap javascript file included in your master page, which I assume must already be there if you have a modal popup that is popping up as normal.
你需要你的母版页中包含的bootstrap javascript文件,如果你有一个正常弹出的模态弹出窗口,我认为它必须已经存在。
<script language="JavaScript" type="text/javascript" src="bootstrap.min.js"></script>