Disable submit button when loading
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button class="mb-2 btn btn-primary" style="margin: 1em auto">Login</button>
|
<button class="mb-2 btn btn-primary" v-bind:disabled="loading" style="margin: 1em auto">Login</button>
|
||||||
<div class="alert alert-danger" v-if="error"><b>Error: </b>{{error}}</div>
|
<div class="alert alert-danger" v-if="error"><b>Error: </b>{{error}}</div>
|
||||||
<div class="alert alert-success" v-if="success">
|
<div class="alert alert-success" v-if="success">
|
||||||
<b>Success! </b>This page will reload soon, your browser will ask you for
|
<b>Success! </b>This page will reload soon, your browser will ask you for
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
return {
|
return {
|
||||||
error: null,
|
error: null,
|
||||||
success: false,
|
success: false,
|
||||||
|
loading: false,
|
||||||
passwordData: {
|
passwordData: {
|
||||||
newUsername: "sunshine",
|
newUsername: "sunshine",
|
||||||
newPassword: "",
|
newPassword: "",
|
||||||
@@ -71,10 +72,12 @@
|
|||||||
methods: {
|
methods: {
|
||||||
save() {
|
save() {
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
this.loading = true;
|
||||||
fetch("/api/password", {
|
fetch("/api/password", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(this.passwordData),
|
body: JSON.stringify(this.passwordData),
|
||||||
}).then((r) => {
|
}).then((r) => {
|
||||||
|
this.loading = false;
|
||||||
if (r.status == 200) {
|
if (r.status == 200) {
|
||||||
r.json().then((rj) => {
|
r.json().then((rj) => {
|
||||||
if (rj.status.toString() === "true") {
|
if (rj.status.toString() === "true") {
|
||||||
|
|||||||
Reference in New Issue
Block a user