今天写django项目遇到模态框无法使用的问题,最终花了1小时将其解决。
如下提供两种方法:
- 方法一:jQuery优先于Bootstrap导入,毕竟Bootstrap依赖jQuery,网上大多是犯了导入的错误。
- 方法二:加id值,代码如下
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" id="mymodel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<h1 class="text-center">修改密码</h1>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="form_group">
<label for="">用户名</label>
<input type="text" disabled value="{{ request.user.username }}" class="form-control">
</div>
<div class="form_group">
<label for="">新密码</label>
<input type="password" id="new_password" class="form-control">
</div>
<div class="form_group">
<label for="">确认密码</label>
<input type="password" id="confirm_password" class="form-control">
</div>
</div>
</div>
</div>
</div>
</div>
调用模态框:
<li><a href='#' data-toggle="modal" data-target="#mymodel">修改密码</a></li>
这里只有两个重要属性:
- data-toggle
- data-target
将原本的 data-target=’.modal-dialog modal-lg’
改为 data-target=’#mymodal’
即可正常使用模态框
版权声明:本文为General_zy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。