jquery-smartwizard icon indicating copy to clipboard operation
jquery-smartwizard copied to clipboard

reset wizard when page reload

Open enneffesviluppo opened this issue 2 years ago • 1 comments

on v5 when i reload the page the wizard start from last visited step, and not from first step. I tried add this code $(window).on('beforeunload', function() { // Reset Smart Wizard state $wizard.smartWizard('reset'); $wizard.smartWizard("goToStep", 0); return 'Are you sure you want to leave?'; });

but doesn't work any idea?

enneffesviluppo avatar Aug 26 '23 15:08 enneffesviluppo

On my hand, I was able to deal with events to solve this issue, don't know if it can work for you.

// Init a variable somewhere to prevent infinite loops
let hasBeenReset = false;

$('#smartwizard').on("loaded", function(e) {
    if (!hasBeenReset) {
        hasBeenReset = true;
        $(this).smartWizard('reset');
    }
});

I think it shouldn't be placed in the initialized event, as it wasn't working for me.

aleaforny avatar Jun 05 '24 15:06 aleaforny