为什么这些确认模式没有出现

Why these confirmation modal is not showing up?

本文关键字:模式 确认 为什么      更新时间:2023-09-26

我使用一个使用bootstrap的模板。我在显示模态时遇到了麻烦。

表单有一个jquery验证,如果一切正常,那么当点击提交时,应该出现一个确认模式,询问用户是否确定要存储该信息。如果表单没有通过验证,则会显示一条简单的消息。对于上述操作,我构建如下:

    <form action="#" id="form_sample_2" class="form-horizontal">
        <div class="alert alert-error hide">
            <button class="close" data-dismiss="alert"></button>Existen errores en el formulario. Por favor verifique.</div>
        <!-- modal -->
        <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h3 id="myModalLabel3">Cargar Usuario</h3>
            </div>
            <div class="modal-body">
                <p></p>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">Cerrar</button>
                <button data-dismiss="modal" class="btn green" id="btnYes">Confirmar</button>
            </div>
        </div>
        <!-- end modal -->
    </form>

正如你所看到的,modal和error message的属性是"hide"…

var handleValidation2 = function () {
        // for more info visit the official plugin documentation: 
        // http://docs.jquery.com/Plugins/Validation
        var form2 = $('#form_sample_2');
        var error2 = $('.alert-error', form2);
        var success2 = $('#myModal', form2);
        //IMPORTANT: update CKEDITOR textarea with actual content before submit
        form2.on('submit', function () {
            for (var instanceName in CKEDITOR.instances) {
                CKEDITOR.instances[instanceName].updateElement();
            }
        })
        form2.validate({
            errorElement: 'span', //default input error message container
            errorClass: 'help-inline', // default input error message class
            focusInvalid: false, // do not focus the last invalid input
            ignore: "",
            rules: {
                //some code
            },
            submitHandler: function (form) {
                success2.show();
                error2.hide();
            }
            //some code

在这个代码片段中,如果表单没有通过验证,那么error2.hide()函数将显示警告错误消息。

当表单通过验证时,success2.show()函数应该显示确认模式,但它没有这样做。当形式ok时,什么也没有出现,我想知道我做错了什么。

任何帮助都将非常感激。

j .

success2.modal('show')代替success2.show();

这应该能解决你的问题

submitHandler: function (form) {
                success2.removeAttr('aria-hidden');
                success2.show();
                error2.hide();
}

是否尝试删除隐藏的变量。