Going to a custom step with jQuery-steps

前端 未结 15 1066
粉色の甜心
粉色の甜心 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:03

    Created this new function:

    function _goToStep(wizard, options, state, index)
    {
        return paginationClick(wizard, options, state, index);
    }
    And the call that is not implemented, put this:
    

    Call that is not implemented, put this:

    $.fn.steps.setStep = function (step)
    {
    
        var options = getOptions(this),
            state = getState(this);
    
        return _goToStep(this, options, state, index); //Index Instead step
    
    };
    
    wizard.steps("setStep", 1);
    

    works just fine

    0 讨论(0)
  • 2020-12-28 17:07
    onInit: function(event) {
            let div = event.currentTarget;
            let lis = div.getElementsByTagName('li');
            // Choose second tab
            // active is just show style, only effective after clicking tag a.
            lis[1].className += ' active';
            $(lis[1]).children('a').click();
        }
    
    0 讨论(0)
  • 2020-12-28 17:07

    This is the simplest solution i found.

    1. Find your tablist item id (in my case it is '#ef_users_list-t-')
    2. Trigger click event
    var tablist_item = 'ef_users_list-t-';
    
    var step = 2; // step number to jump to
    $(tablist_item+step).trigger('click');
    
    0 讨论(0)
  • 2020-12-28 17:08

    take the id of the step you want go and add a trigger!

    $("#steps-uid-0-t-1").trigger("click");
    
    0 讨论(0)
  • 2020-12-28 17:09

    I did this so I created this new function:

    function _goToStep(wizard, options, state, index)
    {
        return paginationClick(wizard, options, state, index);
    }
    

    And the call that is not implemented, put this:

    $.fn.steps.setStep = function (step)
    {
    
        var options = getOptions(this),
            state = getState(this);
    
        return _goToStep(this, options, state, step);
    
    };
    

    Just taking advantage of what already existed plugin.

    Use:

    wizard.steps("setStep", 1);
    
    0 讨论(0)
  • 2020-12-28 17:09

    Basing on @AbdulJamal answer, I've implemented it for any step:

    $(function () {
        var stepsWizard = $("#wizard").steps({
            ...
        });
    
        // step variable handles current step (from 0)
        for(var i=0; i<step; i++) {
            stepsWizard.steps("next");
        }
    });
    

    Note that step variable must be defined and equal or greater than 0.

    0 讨论(0)
提交回复
热议问题