Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset wizard when page reload #175

Open
enneffesviluppo opened this issue Aug 26, 2023 · 1 comment
Open

reset wizard when page reload #175

enneffesviluppo opened this issue Aug 26, 2023 · 1 comment

Comments

@enneffesviluppo
Copy link

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?

@aleaforny
Copy link

aleaforny commented Jun 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants