【发布时间】:2020-09-09 13:37:44
【问题描述】:
我正在学习如何在页面加载时弹出模式。例如,当我单击 home.html 中链接到comment.html 的按钮时,当comment.html 加载时会弹出模态。但是,如果我导航到 comment.html 而不单击按钮,则不会弹出模式。仅当我单击按钮时才弹出模式。
home.html
<!-- Another button that linked to comment without mod data-target -->
# I do not want Modal to popup in comment.html when I click on this button
<a href="{% url 'site:comment' %}">Comment</a>
<!-- Button trigger modal -->
# I want modal to popup in comment.html when I click on this button
<a href="{% url 'site:comment' %}" data-toggle="modal" data-target="#basicExampleModal">
Launch Modal in Comment
</a>
comment.html
<!-- Modal -->
<div class="modal fade" id="basicExampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
【问题讨论】:
标签: javascript jquery mdbootstrap