diff --git a/tailbone/static/js/tailbone.buefy.oncebutton.js b/tailbone/static/js/tailbone.buefy.oncebutton.js index 47dbf79f..3af53276 100644 --- a/tailbone/static/js/tailbone.buefy.oncebutton.js +++ b/tailbone/static/js/tailbone.buefy.oncebutton.js @@ -8,10 +8,10 @@ const OnceButton = { ':tag="tag"', ':href="href"', ':title="title"', - ':disabled="disabled"', + ':disabled="buttonDisabled"', '@click="clicked"', '>', - '{{ text }}', + '{{ buttonText }}', '' ].join(' '), @@ -27,17 +27,39 @@ const OnceButton = { disabled: Boolean }, + data() { + return { + currentText: null, + currentDisabled: null, + } + }, + + computed: { + buttonText: function() { + return this.currentText || this.text + }, + buttonDisabled: function() { + if (this.currentDisabled !== null) { + return this.currentDisabled + } + return this.disabled + }, + }, + methods: { clicked(event) { - this.disabled = true + this.currentDisabled = true if (this.workingText) { - this.text = this.workingText + this.currentText = this.workingText } else if (this.working) { - this.text = this.working + ", please wait..." + this.currentText = this.working + ", please wait..." } else { - this.text = "Working, please wait..." + this.currentText = "Working, please wait..." } + this.$nextTick(function() { + this.$emit('click', event) + }) } }