Going to a custom step with jQuery-steps

前端 未结 15 1067
粉色の甜心
粉色の甜心 2020-12-28 16:46

I am using a jQuery-steps on my app to for a wizard-like situation. I am having trouble finding out how to change to a custom step though. Any help with this one?

         


        
相关标签:
15条回答
  • 2020-12-28 17:12

    Check my following implementation, What do you think guys?

    $.fn.steps.setStep = function (step)
    {
      var currentIndex = $(this).steps('getCurrentIndex');
      for(var i = 0; i < Math.abs(step - currentIndex); i++){
        if(step > currentIndex) {
          $(this).steps('next');
        }
        else{
          $(this).steps('previous');
        }
      } 
    };
    

    And you can execute the new method very easy:

    $("#form").steps("setStep", 4); //based on 0 (set the index)
    

    Regards, Nicholls

    0 讨论(0)
  • 2020-12-28 17:16
    function GotoSpecificStep(action, currentStep, number) {
        try
        {
            var stepsTogo = parseInt(currentStep) - parseInt(number);
            for (i = 1; i <= Math.abs(parseInt(stepsTogo)) ; i++) {
                if (action == "next") {
                    $(".btnNext").click();
                }
                else if (action == "prev") {
                    $(".btnPrevious").click();
                }
            }
        }
        catch(exception)
        {
            MsgBox(exception.message);
        }
    }
    
    0 讨论(0)
  • 2020-12-28 17:16

    I did something like below to get it worked:

    stepsWizard = $("#wizard").steps({
        headerTag: "h2",
        bodyTag: "section"
    });
    
    var indx = 3;
    for (i = 0; i <= indx; i++) {
     stepsWizard.steps("next");
    }
    
    0 讨论(0)
提交回复
热议问题