如何通过变量 bootstrap 模态弹出窗口?
How to bootstrap modal popup via a variable?
我正在研究bootstrap,照着做吧:
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Shows the modal
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
<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">
模态框(Modal)标题
</h4>
</div>
<div class="modal-body">
在这里添加一些文本
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary">
提交更改
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
如果我单击按钮,模态将弹出,但我不明白哪个变量控制模态弹出并消失。
我想通过一个变量来弹出它。有一个要求。
当我进入Smarty 页面时,如果该页面不存在access_token 变量,我希望自动弹出模态。
那么,本例中如何实现呢?
- 用JavaScript(jQuery),select模态元素存入变量
触发show方法
var myModal = $("#myModal");
myModal.modal("show");
显示模态:
$('#myModal').modal('show');
隐藏模态:
$('#myModal').modal('hide');
我正在研究bootstrap,照着做吧:
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Shows the modal
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
<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">
模态框(Modal)标题
</h4>
</div>
<div class="modal-body">
在这里添加一些文本
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary">
提交更改
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
如果我单击按钮,模态将弹出,但我不明白哪个变量控制模态弹出并消失。
我想通过一个变量来弹出它。有一个要求。
当我进入Smarty 页面时,如果该页面不存在access_token 变量,我希望自动弹出模态。
那么,本例中如何实现呢?
- 用JavaScript(jQuery),select模态元素存入变量
触发show方法
var myModal = $("#myModal"); myModal.modal("show");
显示模态: $('#myModal').modal('show');
隐藏模态: $('#myModal').modal('hide');