jquery-smartwizard
jquery-smartwizard copied to clipboard
reset wizard when page reload
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?
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.