Skip verification when returning to SmartWizard

I am using SmartWizard 2.0 ( link ), and I need to stop checking when users click the "Prev" button or move backward in the form in some way.

I am currently using

// Triggers whenever you change page/tab in wizard    
function leaveStep(obj) {        
    $("form").validate();
    if ($("form").valid())
        return true;

    return false;
}

I know I can use

var currentStep = obj.attr('rel'); // get the current step number

to find currentStep, but I need to know which way the user is heading, so I need to know "nextStep". I don’t know if this is possible.

+5
source share
3 answers

When it works onLeaveStep, you can not use obj to determine the direction? Then will you only check when moving on to the next step?

Updated:

, . . jquery.smartWizard-2.0.js 186

if(!options.onLeaveStep.call(this,$(curStep))){

if(!options.onLeaveStep.call(this,$(curStep),$(selStep))){

, , . onLeaveStep, :

// Triggers whenever you change page/tab in wizard    
function leaveStep(from, to) {
    var fromStepIdx = from.attr( "rel" );
    var toStepIdx = to.attr( "rel" );

    if ( toStepIdx < fromStepIdx )
    {
        return true;
    }

    $("form").validate();
    if ($("form").valid())
        return true;

    return false;
}
+7

, - ( - , - ): github.

, "fromStep" "toStep" .

:

$('#wizard').smartWizard({
    onLeaveStep:function(obj, context) {
        if (context.fromStep > context.toStep) {
            // Going backward
        } else {
            // Going forward
        }
    }
});
+12

Mark the answer correctly, you can use context.fromText and context.toStep to determine the direction, but I found that without return true;, smartWizard may not check the transition (the transition from step 1 to 2 is allowed, not step 1 to 3, etc. .) And allow it.

$('#wizard').smartWizard({
onLeaveStep:function(obj, context) {
    if (context.fromStep > context.toStep) {
        // Going backward
    } else {
        // Going forward
    }
    return true;
}
});
+5
source

All Articles