Reputation: 31
I am using jquery smartwizard My wizard opens in a dialog when a user clicks on a button named "create". When the user clicks the button again, I want the wizard to reset and start a fresh wizard but it retains its state. If i reinitialize it, then it adds the next, previous and finish buttons again and messes the entire wizard UI. Any ideas how I can reset the smart wizard?
Upvotes: 3
Views: 8451
Reputation: 18339
Depending on which dialog you are using, I think what you will need to do is the following:
Here is a demo using colorbox:
http://jsfiddle.net/lucuma/Kn2ud/4/
Edit: Since the fiddle is no longer working due to the movement of libraries from when it was created, the code is below:
$("button").colorbox({
inline: true,
open: true,
width: "1000px",
href: '.inline',
onClosed: function() {
$('.inline .swMain').remove();
},
onOpen: function() {
$('.template').clone().removeClass('template').appendTo('.inline').smartWizard({
transitionEffect: 'slideleft',
onFinish: onFinishCallback
});
}
});
Upvotes: 3
Reputation: 1884
Wizard reset public method is included in the latest Smart Wizard 4, see the example.
$('#smartwizard').smartWizard("reset");
Calling this function will reset the wizard to the initial default state.
Upvotes: 6
Reputation: 2148
This seems to work for me (in coffeescript, but you get the idea).
numSteps = 5
wizardDiv.smartWizard('goToStep', 1)
# disable all the following steps
for i in [2..numSteps]
wizardDiv.smartWizard('disableStep', i)
Clearing out or retaining any data in the wizard itself is up to you.
Upvotes: 1