vivek jain
vivek jain

Reputation: 31

reset jquery smartwizard

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

Answers (3)

lucuma
lucuma

Reputation: 18339

Depending on which dialog you are using, I think what you will need to do is the following:

  1. Create a template for your wizard element that is hidden
  2. When you open the dialog (onOpen), clone the element and apply the smartwizard
  3. When the dialog is closed, remove the element that you've cloned.

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

Dipu Raj
Dipu Raj

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

voodoogiant
voodoogiant

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

Related Questions