【发布时间】:2021-06-09 11:13:08
【问题描述】:
我不知道,为什么每次刷新都会执行“onclick”操作(在按钮上或 - 我都尝试过)。当我打开这个页面时,我可以观察到与“set_active_experiment()”和“create_experiment()”相关的动作。我只想在单击链接/按钮时调用这些函数。你有什么想法吗?
代码:
<html>
<head>
<title>Experiments</title>
</head>
<body>
<div class="experiments">
<h3>Your experiments:</h3>
{% with experiments = get_user_experiments() %}
{% if experiments %}
{% for exp in experiments %}
<a href="{{ url_for('experiment') }}"><button onclick="{{ set_active_experiment(exp) }}">{{ exp }}</button></a>
{% endfor %}
{% endif %}
{% endwith %}
</div>
<div>
<a href="{{ url_for('experiments') }}"><button onclick="{{ create_experiment() }}">Create new experiment</button></a>
</div>
</body>
【问题讨论】:
-
请添加你的JS函数。
标签: html flask button onclick jinja2