我有一个表来显示我的应用程序中的操作列表。我可以删除该表中的任何操作。所以,我在每一行添加了一个删除按钮。此删除按钮将触发“删除确认”引导模式。你知道吗
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" class="th-lg">Name</th>
</tr>
</thead>
{% for action in actions_list %}
<tbody>
<tr class="test">
<th scope="row" class="align-middle">{{ forloop.counter }}</th>
<td class="align-middle">
{{action.action_name}}
</td>
<td class="align-middle">
{{action.id}}
</td>
<td>
<div class="row justify-content-end">
<button
id="edit"
type="button"
class="btn btn-sm btn-dark col col-lg-2"
style="color: rgb(255,0,0,0)"
>
<i class="lni-pencil"></i>
</button>
<button
id="trash"
type="button"
class="btn btn-sm btn-dark col col-lg-2"
style="color: rgb(255,0,0,0)"
data-toggle="modal"
data-target="#modalConfirmDelete"
>
<i class="lni-trash"></i>
</button>
</div>
</td>
</tr>
</tbody>
{% endfor %}
</table>
下面是“删除确认”引导模式的代码。它将有“是”和“否”按钮。 如果单击“是”,则该特定操作id将被传递到URL,并且该特定操作id将被删除。你知道吗
{% block modalcontent %}
<!--Modal: modalConfirmDelete-->
<div
class="modal fade"
id="modalConfirmDelete"
tabindex="-1"
role="dialog"
aria-labelledby="exampleModalLabel"
aria-hidden="true"
>
<div class="modal-dialog modal-sm modal-notify modal-danger" role="document">
<!--Content-->
<div class="modal-content text-center">
<!--Header-->
<div class="modal-header d-flex justify-content-center">
<p class="heading">Are you sure?</p>
</div>
<!--Body-->
<div class="modal-body">
<i class="fas fa-times fa-4x animated rotateIn"></i>
</div>
<!--Footer-->
<div class="modal-footer flex-center">
<form action="{% url 'delete_action' aid=action.id %}">
{% csrf_token %}
<button class="btn btn-outline-danger">Yes</button>
</form>
<a
type="button"
class="btn btn-danger waves-effect"
data-dismiss="modal"
>No</a
>
</div>
</div>
<!--/.Content-->
</div>
</div>
{% endblock %}
在上面的代码中,我为delete操作使用了一个表单标记,然后该操作id URL将被触发。你知道吗
下面是删除操作的URL
re_path(r'^delete_action/(?P<aid>\d+)/',
views.delete_action, name='delete_action')
我面临的问题: 我需要操作id在模态中的值,我没有得到!你知道吗
请帮我解决这个问题。提前感谢:)
试试这个
你的模态
相关问题 更多 >
编程相关推荐