在智能向导退步的时候跳过验证 [英] Skip validation when going backwards in SmartWizard

查看:189
本文介绍了在智能向导退步的时候跳过验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的SmartWizard 2.0(链接),我需要停止验证从当用户点击了preV按钮,或以任何方式踢的形式向后移动。

I am using the SmartWizard 2.0 (link) and I need to stop the validation from kicking in when the users hits the "Prev" button or in any way moves backward in the form.

目前我使用

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

    return false;
}

我知道,我可以使用

I know that I can use

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

找currentStep,但我需要知道用户正在浏览哪个方向 - 所以我需要知道NextStep自动。不知道这是可能的。

to find the currentStep, but I need to know which way the user is navigating - so I need to know the "nextStep". Don't know if this is possible.

推荐答案

onLeaveStep 触发你能不能用OBJ来确定方向?然后,你会移动到下一个步骤时,只验证?

When onLeaveStep is triggered could you not use the obj to determine the direction? Then you would only validate when moving to the next step?

更新:

查看源$ C ​​$ C后,没有办法,我可以看到找出方向。在能力修补然而pretty容易。在jquery.smartWizard-2.0.js变线186

After looking at the source code, there is no way that I can see to figure out the direction. Patching in the ability is pretty easy however. In jquery.smartWizard-2.0.js change line 186 from

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

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

这现在可以访问所选步骤锚,因此所选择的阶跃折射率。要在onLeaveStep处理简单的确定方向做到以下几点:

This now gives you access to the selected step anchor, and thus the selected step index. To determine the direction in your onLeaveStep handler simple do the following:

// 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;
}

这篇关于在智能向导退步的时候跳过验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆