app: Fix javascript doesn't run on first visit

Merge Request !1644 fixed the 'const redeclaration' error but introduced
another issue - javascript on the app configuration page doesn't run
on first visit.

Relates to #1715

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Veiko Aasa 2019-12-09 16:02:00 +03:00 committed by James Valleroy
parent fe121e1fab
commit 851d1c7c28
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -21,14 +21,13 @@
* in this page. * in this page.
*/ */
$(document).on('turbolinks:load', function() { var appForm = document.querySelector('#app-form');
const appForm = document.querySelector('#app-form'); var appToggleContainer = document.querySelector('#app-toggle-container');
const appToggleContainer = document.querySelector('#app-toggle-container'); var appToggleButton = document.querySelector('#app-toggle-button');
const appToggleButton = document.querySelector('#app-toggle-button'); var appToggleInput = document.querySelector('#app-toggle-input');
const appToggleInput = document.querySelector('#app-toggle-input');
if (appForm && appToggleButton && appToggleInput && appToggleContainer) { if (appForm && appToggleButton && appToggleInput && appToggleContainer) {
const onSubmit = (e) => { var onSubmit = (e) => {
e.preventDefault; e.preventDefault;
appToggleInput.checked = !appToggleInput.checked; appToggleInput.checked = !appToggleInput.checked;
appForm.submit(); appForm.submit();
@ -55,4 +54,3 @@ $(document).on('turbolinks:load', function() {
appForm.previousElementSibling.style.display = 'none'; appForm.previousElementSibling.style.display = 'none';
} }
} }
});