1

基本的に、「次へ」ボタンがクリックされたときにデータを検証する必要がありますが、ユーザーが戻りたい場合、現在のステップに必要なフィールドが導入されているかどうかを検証したくありません

    $('#wizard').smartWizard({ onLeaveStep: leaveAStepCallback,
            onFinish: onFinishCallback
        });

        function leaveAStepCallback(obj) {
            var step_num = obj.attr('rel'); // get the current step number
            return validateSteps(step_num); // return false to stay on step and true to continue navigation 
        }

        function onFinishCallback() {
            if (validateAllSteps()) {
                $('form').submit();
            }
        }

        // Your Step validation logic
        function validateSteps(stepnumber) {
            var isStepValid = true;

            if (stepnumber == 1) {
                var e = document.getElementById("ContentPlaceHolder1_DropDownCustomers");
                var strCustomer = e.options[e.selectedIndex].value;
                if (strCustomer == "-1") {
                    //alert("Please select a Customer.");
                    $('#wizard').smartWizard('showMessage', 'Please select a Customer.');
                    isStepValid = false;
                    return isStepValid;
                }
                else {
                    var d = document.getElementById("ContentPlaceHolder1_DropDownTemplates");
                    var strTemplate = d.options[d.selectedIndex].value;
                    if (strTemplate == "-1") {
                        alert("Please select a Template.");
                        isStepValid = false;
                        return isStepValid;
                    }
                    else {
                        return isStepValid;
                    }
                    return isStepValid;
                }
            }

            if (stepnumber == 2) {

                if (document.getElementById("ContentPlaceHolder1_LabelMainDestData") != null) {
                    isStepValid = true;
                }
                else {
                    alert("Please introduce the Main Destination.");
                    isStepValid = false;
                }


                return isStepValid;

            }

            if (stepnumber == 3) {
                isStepValid = true;
                return isStepValid;
            }

        }
4

6 に答える 6

3

showStep関数で編集するだけ

if(stepIdx != curStepIdx)

if(stepIdx > curStepIdx)

それはあなたの問題を解決します

于 2012-12-03T00:46:14.407 に答える
1

新しい変数を作成します。

var OO_Back = false;

次に、戻るボタンをクリックしたときに「OO_Back=true」を追加します。

$($this.buttons.previous).click(function() {
    OO_Back = true;
    $this.goBackward();
    return false;
});

最後にこの条件を変更して、y戻るボタンがクリックされたことを確認します。その後、OO_Back=falseを設定する必要があります。

 var curStep = $this.steps.eq($this.curStepIdx);
    if(stepIdx != $this.curStepIdx){
        if($.isFunction($this.options.onLeaveStep) && OO_Back == false) {
            var context = { fromStep: $this.curStepIdx+1, toStep: stepIdx+1 };
            if (! $this.options.onLeaveStep.call($this,$(curStep), context)){
                return false;
            }
        }
    }
 OO_Back = false;
于 2012-02-12T20:09:38.940 に答える
0

私は以下を使用しましたが、上記の受け入れられた回答に導かれて完全に機能しました。

onLeaveStep: function(obj, context){
       if(context.toStep > context.fromStep){ ...}
  }
于 2013-08-30T01:15:03.180 に答える
0

私がそれを使用したとき、これは私のために働いた:

 function leaveStep(oStep, context) {
   //don't validate if the user is going backwards    
    if (context.toStep < context.fromStep)
    {
        $('#wizard').smartWizard('hideMessage');
        return true;
    }
   // continue to validate steps...
于 2015-06-29T20:31:49.993 に答える
0

リクエストから取得できるstep_numberプロパティにケースを使用して別のjspページを作成し、そのjsp内にstep_numberに従ってjspを含め、新しく作成したjspをcontentURLに割り当てます

//inside your wizard page.
contentURL:'wizardcontent.jsp',

//'wizardcontent.jsp' is as follow

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
    int step_number = Integer.parseInt(request.getParameter("step_number")!=null?request.getParameter("step_number"):"1");
    String url = "";
    switch (step_number){
        case 1:%>
            <jsp:include page="ddd.jsp"></jsp:include>
        <%break;
        case 2:%>
            <jsp:include page="xyz.jsp"></jsp:include>
        <%break;
        case 3:%>
            <jsp:include page="abcd.jsp"></jsp:include>
                   <%break;
    }

%>
于 2011-09-09T09:14:26.133 に答える
0

多分これは助けることができます:

       $('.buttonPrevious').click(function () {
            // set true validation if you need
            return false;
        });

必要に応じて、戻るボタンに有効な true を設定する必要があります。

キャンセルされた leaveAStepCallback 関数に対してこれを試してください。

       $('#yourwizard').unbind('leaveAStepCallback'); 

うまくいかない場合は、stopImmediatePropagationをチェックしてください。

于 2012-02-10T10:48:37.017 に答える