Uncaught Referenceerror: alerta is not defined

Asked

Viewed 342 times

1

Hello, I have an undefined function problem in a code snippet. I’m using Django, but when I try to call a function occurs the undefined function error

index.html

{% if valueStatus == 0 %}
<script>
alerta();
</script>
{% else %}
<script>
toggleOnByInput()
</script>
{% endif %}


<script src="{% static 'js/jquery.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.js' %}"></script>
<script src="{% static 'js/bootstrap4-toggle.min.js' %}"></script>
<script src="{% static 'js/Chart.bundle.js' %}"></script>
<script src="{% static 'js/Gauge.js' %}"></script>
<script src="{% static 'js/scripts.js' %}"></script>

js scripts.

function toggleOnByInput() {
    $('#statusLinha').prop('checked', true).change()
}

function toggleOffByInput() {
    $('#statusLinha').prop('checked', false).change()
}

function alerta() {
    alert("Alerta");
}
  • Put the line <script src="{% static 'js/scripts.js' %}"></script> before the line where you call the function...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.