mstratman / jQuery-Smart-Wizard

flexible jQuery plug-in that gives wizard like interface
http://mstratman.github.com/jQuery-Smart-Wizard/
304 stars 164 forks source link

How to Hide Finish button untill Last Tab #29

Closed velanchandru closed 8 years ago

velanchandru commented 11 years ago

Hi guys,

i want hide the Finish button while coming backwards.i want to show only if the user in the last step and sample code on how to use on showstep, i know its possible to set this in onShowstep but if i did something in the onShowstep method Wizard not render properly it gets collapsed i tried the following but no luck.

as StuartMorris said:

onShowStep: function(){ var currentStep = $("#wizard").smartWizard("currentStep"); if(currentStep) { HideShowSubmit(currentStep); }

function HideShowSubmit(step) {

            var LastTab = Tabs.length; //Total listitem length
            console.log('step: ' + step + ' LastTab: ' + LastTab);
            if (step == LastTab) {

                $('#wizard').smartWizard('setFinishButton', true);
                console.log('show');
            } else {
                $('#wizard').smartWizard('setFinishButton', false);
                console.log('hide');
            }

        }
sandipwane commented 8 years ago

call this function in show step callback function fnDisableFinishButton(iCurrentStep, iFinishStep, oFinishButton) { oFinishButton = oFinishButton || $(".actionBar .buttonFinish") iFinishStep = iFinishStep || 3 if (oFinishButton && iCurrentStep == iFinishStep) { oFinishButton.removeClass('buttonDisabled') } else if (oFinishButton) { oFinishButton.addClass('buttonDisabled') } }`

StateBarofArizona commented 8 years ago

What values do I pass into this new function?

onesinus commented 6 years ago

Hei,

I just found this solutions, just add this simple code in every step in wizard

if($('button.sw-btn-next').hasClass('disabled')){
                $('.sw-btn-group-extra').show(); // show the button extra only in the last page
            }else{
                $('.sw-btn-group-extra').hide();                
            }

Here Is The Full Code :

$("#smartwizard").on("showStep", function(e, anchorObject, stepNumber, stepDirection) {
            if($('button.sw-btn-next').hasClass('disabled')){
                $('.sw-btn-group-extra').show(); // show the button extra only in the last page
            }else{
                $('.sw-btn-group-extra').hide();                
            }

          });

The Explanation is so simple,showStep function handle every step in wizard ( from step 1 to 2, etc ) Then we just need to check is button with class btn-next(class next button) has disabled class, as we know the next button disabled when the page is last.

Hope this help.

fcopaveltorres commented 3 years ago

Hi, Solution

$("#smartwizard").on("showStep", function (e, anchorObject, stepIndex, stepDirection) {
        setTimeout(function () {
            if ($('button.sw-btn-next').hasClass('disabled')) {
                $('.finish').show(); // show the button extra only in the last page
            } else {
                $('.finish').hide();
            }
        }, 500);

    });
ghassanhjr commented 2 years ago

you made my day