fix reload after submit
This commit is contained in:
parent
71e1ec06e4
commit
63b76e1579
|
|
@ -25,7 +25,7 @@ def create_conditions_routes(app):
|
||||||
data = request.form.to_dict()
|
data = request.form.to_dict()
|
||||||
|
|
||||||
result = r.table(table_name).insert(data).run(get_connection())
|
result = r.table(table_name).insert(data).run(get_connection())
|
||||||
return redirect(request.referrer or url_for('index'))
|
return render_template(route + '/create.html')
|
||||||
|
|
||||||
# Read operation
|
# Read operation
|
||||||
@app.route('/' + route, methods=['GET'])
|
@app.route('/' + route, methods=['GET'])
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,12 @@ document.addEventListener('DOMContentLoaded', documentReady, false);
|
||||||
function documentReady() {
|
function documentReady() {
|
||||||
const iframe = document.querySelector("iframe");
|
const iframe = document.querySelector("iframe");
|
||||||
const dialog = document.querySelector("dialog");
|
const dialog = document.querySelector("dialog");
|
||||||
iframe.onload = () => {
|
iframe.onload = (event) => {
|
||||||
dialog.style.height = iframe.contentWindow.document.body.getBoundingClientRect().height + "px";
|
dialog.style.height = iframe.contentWindow.document.body.getBoundingClientRect().height + "px";
|
||||||
|
if (event.target.contentWindow.location.search.includes("submitted")) {
|
||||||
|
dialog.close();
|
||||||
|
window.location.href=window.location.href
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h2>Create a condition</h2>
|
<h2>Create a condition</h2>
|
||||||
<form method="POST" action="/conditions">
|
<form method="POST" action="/conditions?submitted">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="symbol">Symbol</label>
|
<label for="symbol">Symbol</label>
|
||||||
<input type="text" name="symbol">
|
<input type="text" name="symbol">
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<button value="cancel" formmethod="dialog" onclick="window.top.postMessage('close', '*')">Cancel</button>
|
<button value="cancel" formmethod="dialog" onclick="window.top.postMessage('close', '*')">Cancel</button>
|
||||||
<button type="submit">Submit</button>
|
<button type="submit" >Submit</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h2>Update a condition</h2>
|
<h2>Update a condition</h2>
|
||||||
<form method="POST" action="/conditions/{{ data.id }}">
|
<form method="POST" action="/conditions/{{ data.id }}?submitted">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
<div>{{ data.id }}</div>
|
<div>{{ data.id }}</div>
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
<button type="submit">Submit</button>
|
<button type="submit">Submit</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<form method="POST" action="/conditions/delete/{{ data.id }}">
|
<form method="POST" action="/conditions/delete/{{ data.id }}?submitted">
|
||||||
<button class="danger" type="submit">Delete</button>
|
<button class="danger" type="submit">Delete</button>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Trading Zone Website</title>
|
<title>Trading Zone Website</title>
|
||||||
|
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/styles.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/styles.css') }}">
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='js/main.js') }}" ></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='js/main.js') }}" ></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue