fix: error togging unexpectedly

feat/muzan
Evan Chen 2021-11-11 10:05:55 +08:00
parent eddd813846
commit acec4a6af9
1 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{{define "components/error"}} {{define "components/error"}}
<div class="notification is-danger {{if not .Error}}is-hidden{{end}}" id="error_view"> <div class="notification is-danger {{if not .Error}}is-hidden{{end}}" id="error_view">
<button class="delete" onclick="ErrorTog()"></button> <button class="delete" onclick="ErrorClose()"></button>
<p id="err_msg">{{.Error}}</p> <p id="err_msg">{{.Error}}</p>
</div> </div>
<script> <script>
@ -8,10 +8,18 @@ function ErrorTog(){
let el = document.getElementById('error_view'); let el = document.getElementById('error_view');
el.classList.toggle('is-hidden'); el.classList.toggle('is-hidden');
} }
function ErrorOpen(){
let el = document.getElementById('error_view');
el.classList.remove('is-hidden');
}
function ErrorClose(){
let el = document.getElementById('error_view');
el.classList.add('is-hidden');
}
function ShowError(msg){ function ShowError(msg){
let el = document.getElementById('err_msg'); let el = document.getElementById('err_msg');
el.innerHTML = msg; el.innerHTML = msg;
ErrorTog(); ErrorOpen();
} }
</script> </script>
{{end}} {{end}}