From 876d7ac2b41cf3f36f070eb857f07fceaf2c5bc2 Mon Sep 17 00:00:00 2001 From: Guillaume Boudreau Date: Wed, 13 Aug 2014 10:09:08 -0400 Subject: [PATCH] Allow user to re-submit on error When submit fails (error or failure), unlock all the cards and re-enable the Next button, to allow the user to fix the issue and retry. --- src/bootstrap-wizard.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/bootstrap-wizard.js b/src/bootstrap-wizard.js index ec7eed0..a5a90d9 100644 --- a/src/bootstrap-wizard.js +++ b/src/bootstrap-wizard.js @@ -886,6 +886,8 @@ this.updateProgressBar(this.percentComplete); } + this.showButtons(); + return newCard; } else { @@ -921,6 +923,12 @@ return this; }, + unlockCards: function() { + this.log("unlocking nav cards"); + this.eachCard(function(i,card){card.markVisited();}); + return this; + }, + disableCards: function() { this.log("disabling all nav cards"); this.eachCard(function(i,card){card.disable();}); @@ -1089,6 +1097,13 @@ this._submitting = false; this.showSubmitCard("failure"); this.trigger("submitFailure"); + + // Unlock the cards, and reset the buttons, to allow the user to retry + this.unlockCards(); + this.nextButton.hide(); + this.enableNextButton(); + this._readyToSubmit = true; + this.trigger("readySubmit"); }, submitError: function() { @@ -1096,6 +1111,13 @@ this._submitting = false; this.showSubmitCard("error"); this.trigger("submitError"); + + // Unlock the cards, and reset the buttons, to allow the user to retry + this.unlockCards(); + this.nextButton.hide(); + this.enableNextButton(); + this._readyToSubmit = true; + this.trigger("readySubmit"); },