0

私は、プロジェクトで SmartWizard を使用して、Web サイトにユーザーを登録しています。しかし、ウィザードに 4 つのステップがあるステップ 3 ですべてのデータを保存したいと考えています。ウィザードは、完了ボタンをクリックするとフォームを送信します。以下のコードは私の仮定を説明し、これを行う方法を提案できます。ありがとう。

    function validateAllSteps(){
   var isStepValid = true;

   if(validateStep1() == false){
     isStepValid = false;
     $('#wizard').smartWizard('setError',{stepnum:1,iserror:true});         
   }else{
     $('#wizard').smartWizard('setError',{stepnum:1,iserror:false});
   }

   if(validateStep2() == false){
     isStepValid = false;
     $('#wizard').smartWizard('setError',{stepnum:2,iserror:true});         
   }else{
     $('#wizard').smartWizard('setError',{stepnum:2,iserror:false});
   }

   return isStepValid;
}   


    function validateSteps(step){
      var isStepValid = true;

  // validate step 1
  if(step == 1){
    if(validateStep1() == false ){
      isStepValid = false; 
      $('#wizard').smartWizard('showMessage','Please correct the errors in step'+step+  
   ' and click next.');
      $('#wizard').smartWizard('setError',{stepnum:step,iserror:true});         
    }else{
      $('#wizard').smartWizard('setError',{stepnum:step,iserror:false});
    }
  }

  // validate step 2
  if(step == 2){
    if(validateStep2() == false ){
      isStepValid = false; 
      $('#wizard').smartWizard('showMessage','Please correct the errors in step'+step+  
  ' and click next.');
      $('#wizard').smartWizard('setError',{stepnum:step,iserror:true});         
    }else{
      $('#wizard').smartWizard('setError',{stepnum:step,iserror:false});
    }
  }


   return isStepValid;
 }
    //start of step one validation

    //end of of step one validation

//step 2 validation

//end of step 2 validation

var res=validateAllSteps();
if(res == true)
{
    $('#form1').submit();
}
4

2 に答える 2

0

プラグインを変更して、「一部を保存」などの別のボタンを作成します。次に、「onSavePartial」などと呼ばれるイベント ハンドラーを追加します。プラグインの初期化中に、呼び出されるコールバックを追加できます。次に、このコールバック内でフォームを送信します。

 jQuery('#wizard').smartWizard({
 selected:currentStep,
 enableAllSteps:enableSteps,
 transitionEffect:'slideleft',
 onLeaveStep:leaveAStepCallback,
 onFinish:onFinishCallback,
 onSavePartial:onSavePartialCallBack,
 enableFinishButton:false,
 });

そして、これがonSavePartialCallBack関数です

function onContinueLaterCallback(){
    //your validation and other stuff here

    jQuery('form').submit();
}

NBボタンを表示し、onSavePartialのものを処理するには、プラグインをハックする必要があります

于 2013-10-29T09:01:43.027 に答える