mstratman / jQuery-Smart-Wizard

flexible jQuery plug-in that gives wizard like interface
http://mstratman.github.com/jQuery-Smart-Wizard/
303 stars 164 forks source link

onLeaveStep Event Not firing #108

Open aman-saggu-git opened 7 years ago

aman-saggu-git commented 7 years ago

I am using below code everything is working fine but i want to put validation and i used code as per your documentation. but OnLeaveStep event on below code is not even showing alert box Code -

 $('#smartwizard').smartWizard({ 
                labelFinish:'Proceed To Checkout',
                onLeaveStep:  function (obj, context){
                                      alert(obj+context);
                },
                selected: 0, 
                theme: 'arrows',
                transitionEffect:'fade',
                toolbarSettings: {toolbarPosition: 'bottom',
                                      toolbarExtraButtons: [btnFinish],
                             },                                   
                    });
mikeslim7 commented 7 years ago

I think for it to work you need to return true/false. try like this: $('#smartwizard').smartWizard({ onLeaveStep: myFunction }); function myFunction(obj, context){ alert(obj+context); return false; } I have not tested though.

deathgore commented 6 years ago

They work by with $.on hook: var smartWizardElement = $('#smartwizard').smartWizard({........}); smartWizardElement .on('leaveStep', callback); --> this works

Joozty commented 6 years ago

@deathgore Yes you are right but how can I access context.fromStep and context.toStepvariables.

smartWizardElement.on('leaveStep', function(event, context){
    alert("Leaving step " + context.fromStep + " to go to step " + context.toStep);
    // return false to stay on step and true to continue navigation
    return true;
});

This returns undefined: "Leaving step undefined to go to step undefined"