簡體   English   中英

jQuery步驟-重置為主要步驟

[英]jQuery Steps - reset to the main step

我已將這些鏈接重置為第一步,但並沒有幫助。

我在最后一步添加了自定義的“提交”按鈕。 並想重置表格以及在ajax提交上的步驟。

這是我的代碼

$("#employee_create").steps({
    headerTag: "h6",
    bodyTag: "section",
    transitionEffect: "fade",
    titleTemplate: '<span class="step">#index#</span> #title#',
    labels: {
        finish: "Submit"
    },
    onStepChanged: function (event, currentIndex, newIndex) {
        if (currentIndex === 4) { //if last step
            //remove default #finish button
            $('#employee_create').find('a[href="#finish"]').remove();
            //append a submit type button
            $('#employee_create .actions li:last-child').append('<button type="button" id="emp_submit" onclick="empFormSubmit(this)" class="btn btn-primary">Submit <span class="spinner" style="display: none;"><i class="fa fa-circle-o-notch fa-spin"></i></span></button>');
        } else {
            $('#emp_submit').remove();
        }
    },
    onStepChanging: function (event, currentIndex, newIndex) {
        return currentIndex > newIndex || !(3 === newIndex && Number($("#age-2").val()) < 18) && (currentIndex < newIndex && (emp_form.find(".body:eq(" + newIndex + ") label.error").remove(),
                emp_form.find(".body:eq(" + newIndex + ") .error").removeClass("error")),
                emp_form.validate().settings.ignore = ":disabled,:hidden",
                emp_form.valid());
    },
    onFinishing: function (event, currentIndex) {
        return emp_form.validate().settings.ignore = ":disabled",
                emp_form.valid();
    },
    onFinished: function (event, currentIndex) {

    }
}), $("#employee_create").validate({
    ignore: "input[type=hidden]",
    errorClass: "text-danger",
    successClass: "text-success",
    highlight: function (element, errorClass) {
        $(element).removeClass(errorClass);
    },
    unhighlight: function (element, errorClass) {
        $(element).removeClass(errorClass);
    },
    errorPlacement: function (error, element) {
        error.insertAfter(element);
    },
    rules: {
        email: {
            email: !0
        }
    }
});

到目前為止,我嘗試過的是

$('#emp_submit').on('click', function(){
    emp_form[0].reset();
});

我究竟做錯了什么?

我添加了一個自定義腳本來重置步驟,但我發現它不正確。

$('#employee_create-p-0').show();
$('#employee_create-p-4').hide();
$('#employee_create .steps').find('li').removeClass().addClass('disabled');
$('#employee_create .steps li:first').removeClass('disabled').addClass('first current');

如果還有其他可靠的方法,請告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM