Skip to content

Commit

Permalink
skip alert close button if javascript is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
xi committed Jul 17, 2018
1 parent aa111f6 commit f27756f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bootstrap4/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from bootstrap4.utils import render_tag, add_css_class

from .text import text_value
from .bootstrap import get_bootstrap_setting


def render_alert(content, alert_type=None, dismissable=True):
Expand All @@ -15,7 +16,7 @@ def render_alert(content, alert_type=None, dismissable=True):
if not alert_type:
alert_type = "info"
css_classes = ["alert", "alert-" + text_value(alert_type)]
if dismissable:
if dismissable and get_bootstrap_setting("use_javascript"):
css_classes.append("alert-dismissable")
button = (
'<button type="button" class="close" '
Expand Down
3 changes: 3 additions & 0 deletions bootstrap4/templates/bootstrap4/form_errors.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{% load bootstrap4 %}
<div class="alert alert-danger alert-dismissable alert-link">
{% if 'use_javascript'|bootstrap_setting %}
<button class="close" type="button" data-dismiss="alert" aria-hidden="true">&#215;</button>
{% endif %}
{% for error in errors %}
{{ error }}{% if not forloop.last %}<br>{% endif %}
{% endfor %}
Expand Down
2 changes: 2 additions & 0 deletions bootstrap4/templates/bootstrap4/messages.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% load bootstrap4 %}
{% for message in messages %}
<div class="{{ message|bootstrap_message_classes }} alert-dismissable fade show">
{% if 'use_javascript'|bootstrap_setting %}
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&#215;</button>
{% endif %}
{{ message }}
</div>
{% endfor %}

0 comments on commit f27756f

Please sign in to comment.