2013-09-26 14 views
0

IAM在jquery中很新穎。 這裏是jQuery的從smart wizard如何觸發jquery.smart嚮導完成按鈕?

/ Default Properties and Events 
    $.fn.smartWizard.defaults = { 
     selected: 0, // Selected Step, 0 = first step 
     keyNavigation: true, // Enable/Disable key navigation(left and right keys are used if enabled) 
     enableAllSteps: false, 
     transitionEffect: 'fade', // Effect on navigation, none/fade/slide/slideleft 
     contentURL:null, // content url, Enables Ajax content loading 
     contentCache:true, // cache step contents, if false content is fetched always from ajax url 
     cycleSteps: false, // cycle step navigation 
     enableFinishButton: false, // make finish button enabled always 
     hideButtonsOnDisabled: false, // when the previous/next/finish buttons are disabled, hide them instead? 
     errorSteps:[], // Array Steps with errors 
     labelNext:'Next', 
     labelPrevious:'Previous', 
     labelFinish:'Finish', 
     noForwardJumping: false, 
     ajaxType: "POST", 
     onLeaveStep: null, // triggers when leaving a step 
     onShowStep: null, // triggers when showing a step 
     onFinish: null, // triggers when Finish button is clicked 
     includeFinishButton : true // Add the finish button 
    }; 

})(jQuery); 



<script type="text/javascript"> 
     $(document).ready(function() { 
      // Smart Wizard   
      $('#wizard').smartWizard({ 
       onLeaveStep: leaveAStepCallback, 
       onFinish: onFinishCallback 
      }); 

      function leaveAStepCallback(obj, context) { 
       debugger; 
       alert("Leaving step " + context.fromStep + " to go to step " + context.toStep); 
       return validateSteps(context.fromStep); // return false to stay on step and true to continue navigation 
      } 

      function onFinishCallback(objs, context) { 

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

      // Your Step validation logic 
      function validateSteps(stepnumber) { 
       debugger; 
       var isStepValid = true; 
       // validate step 1 
       if (stepnumber == 1) { 
        // Your step validation logic 
        // set isStepValid = false if has errors 
       } 
       // ...  
      } 
      function validateAllSteps() { 
       debugger; 
       var isStepValid = true; 
       // all step validation logic  
       return isStepValid; 
      } 
     }); 
</script> 

我需要一些functione爲onFinish,在那裏我可以有很多參數發送請求。怎麼做?

回答

2

首先從https://github.com/mstratman/jQuery-Smart-Wizard 下載smartWizard.js,然後將它添加到您的工作區中,並在html/jsp中給出參考。

<script type="text/javascript" src="js/jquery.smartWizard-2.1.js"></script> 

然後,

<script type="text/javascript"> 
$(document).ready(function(){ 
    // Smart Wizard  
    $('#wizard').smartWizard(); 
    //$('#range').colResizable(); 

    function onFinishCallback(){ 
     $('#wizard').smartWizard('showMessage','Finish Clicked'); 
    } 
}); 
</script> 
在onFinish的jquery.smartWizard-2.1.js搜索

然後, 只是儘量讓警覺,那麼無論你想添加您可以直接在添加它。 js文件。

-1

//更改結束按鈕的標籤

$( '#嚮導')smartWizard.defaults.labelFinish = 「確認&購買」。

0

添加您的自定義功能,如下所示。

onFinish:函數(){警報( 「!完成被點擊」)} //當單擊Finish按鈕

0

使用下面的代碼觸發,你的表格將被提交。我希望這能幫到您。

var Myform=$('#saveForm'); 
    $(document).on('click','.btn-finish',function(e){ 
     $('#saveForm')[0].submit(); 
    }); 
相關問題