Skip to content

Commit 4541e38

Browse files
committed
Add confirmation alert to delete task if task is not completed
1 parent eef534e commit 4541e38

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

templates/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ <h1>Endless Task List App using Flask</h1>
6868
{% if not task.completed %}<!--show complete button if task is not completed-->
6969
<a href="/complete_task/{{ task.id }}">Complete</a>
7070
{% endif %}
71-
<a href="/delete_task/{{ task.id }}">Delete</a>
71+
<a
72+
href="/delete_task/{{ task.id }}"
73+
onclick="return {{ 'confirm(\'Are you sure you want to delete this task?\')' if not task.completed else 'true' }}"
74+
>Delete</a
75+
><!--confirm user to delete the task if task is not completed, if task is completed don't alert user to confirm task deletion-->
7276
{% endfor %}
7377
</ul>
7478
</ul>

0 commit comments

Comments
 (0)