如何触发jquery.smart向导完成按钮?

时间:2013-09-26 09:18:03

标签: jquery request submit smart-wizard

我在jquery中非常新。 这是来自smart wizard的jquery:

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

我需要onFinish的一些功能,我可以发送带有许多参数的请求。怎么做?

4 个答案:

答案 0 :(得分: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>

然后在jquery.smartWizard-2.1.js中搜索onFinish, 只需尝试发出提醒,然后您想添加的任何内容都可以直接添加到.js文件中。

答案 1 :(得分:0)

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

onFinish:function(){alert(&#34; Finish Clicked!&#34;)},//点击完成按钮后触发

答案 2 :(得分:0)

使用以下代码,您的表单将被提交。我希望这会对你有所帮助。

public IEnumerable<Model> GetModels()  
{  
    return (from t in _database.Table<Model>() select t).ToList();  
}

答案 3 :(得分:-1)

//更改完成按钮的标签

$('#wizard')。smartWizard.defaults.labelFinish =“确认和购买”;