jQuery Steps - reset wizard without page reload

前端 未结 5 2152
攒了一身酷
攒了一身酷 2021-02-15 12:05

I am using jQuery steps ( https://github.com/rstaib/jquery-steps/wiki ) in order to create step by step form to users to fill out. It works great, however I need to be able to r

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-15 12:48

    a small correction with the custom reset function :

    $.fn.steps.reset = function () {
    var wizard = this,
    options = getOptions(this),
    state = getState(this);
    
    if(state.currentIndex>0)
    {
        goToStep(wizard, options, state, 0);   
    
        for (i = 1; i < state.stepCount; i++) {
        var stepAnchor = getStepAnchor(wizard, i);
        stepAnchor.parent().removeClass("done")._enableAria(false);
        }
    }
    };
    

    I added a if, in case you try to reset at step 0.

提交回复
热议问题