I'm completely new to JavaScript and am trying to implement a popup box upon concurrency editing in Django. I've tried using the popUp
function in js but to no avail. Here's my code
html
{% block content %}
<div class="page-header">
{% if is_editable %}
<div>
Got to here
</div>
<!--{% block custom_js %}
<script src="{% static "myapp/form_edit.popup.js" %} type="text/javascript"></script>
{% endblock custom_js %}-->
<script language="JavaScript">
function popUp() {
alert("Be careful!");
}
</script>
{% endif %}
js
<script type="text/javascript">
function popUp() {
alert("try to be careful!");
}
</script>
As can be seen the original intention was just to call a simple js script which produces the popup. This didn't work. So then I simply embedded the js code in the html, and this okay. The line Got to here
is just to test if my if
clause is actually triggered, which it is as the text is shown on my page. How can I get the code from the .js file to be triggered?
Where are you actually calling popUp()
?
Try:
var popUp = function popUp() {
alert("Be careful!");
};
popUp();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.