Sweetalert和jQuery.validationEngine

时间:2015-06-17 19:53:40

标签: jquery submit form-submit jquery-validation-engine sweetalert

我已经在我的jQuery.validationEngine上实现了Sweetalert但是按钮"接受" sweetalert没有运行"提交",可以添加什么才能使其有效?

这是Sweetalert的代码:

                    $(document).ready(function(){
            $("#id_form").validationEngine('attach',{
            onValidationComplete:function(form, status){
            if (status === true){
            if(swal({title: "Confirm text?",text: "Another Text",type: "warning",showCancelButton: true,confirmButtonColor: "#DD6B55",confirmButtonText: "Accept",cancelButtonText: "Cancel"closeOnConfirm: true,closeOnCancel: false})){       

        form.validationEngine('detach');
           submit();
                }}}
            });
           })

没有Sweetalert并且正在运行:

            $(document).ready(function(){
            $("#id_form").validationEngine('attach',{
            onValidationComplete:function(form, status){
            if (status === true){
                if(confirm("Confirm text?")){               

        form.validationEngine('detach');
           submit();
                }}}
            });
        }) 

参考文献:

Sweetalert

jQuery.validationEngine

1 个答案:

答案 0 :(得分:0)

首先你应该在&#34之后插入逗号;取消"串。 根据以下

调整您的代码
swal({
                                title: "Confirm text?",
                                text: "Another Text",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "Accept",
                                cancelButtonText: "Cancel",
                                closeOnConfirm: true,closeOnCancel: false
                            }, function (isConfirm) {
                                if (isConfirm) {
                                    return true;
                                } else {
                                    return false;
                                }
                            });