douren1928 2014-08-18 06:31
浏览 23
已采纳

使用bootstrap模式使用jquery验证加载不同的内容

I'm using bootstrap model to edit table values. It works perfectly. But when I'm using BootstrapValidator plugin to validate that modal there's a problem. Problem is when I click edit first time and load model it works normally. Then if I click edit again in the same page, validation errors belongs to previous one still shows. Screen shot displays here,

enter image description here

Modal Call

<a data-toggle="modal" data-target="#dealModal" onclick="ajax_get_edit_data('.$id.');"></a>

Validations

<script type="text/javascript">
    $(document).ready(function () {     
    $('#dealForm')
        .bootstrapValidator({
            message: 'This value is not valid',
            fields: {
                deal_description: {
                    message: 'The deal discription is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The deal discription is required and can\'t be empty'
                        }
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {
            // Prevent form submission
            e.preventDefault();

            // Get the form instance
            var $form = $(e.target);

            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');

            // Use Ajax to submit form data
            //$.post($form.attr('action'), $form.serialize(), function(result) {
            //  console.log(result);
            //}, 'json');
        });
</script>
  • 写回答

1条回答 默认 最新

  • doujiang1913 2014-08-18 08:13
    关注

    After form is submitted, call resetForm method:

    ...
    var bv = $form.data('bootstrapValidator');
    ...
    // After successful post
    bv.resetForm();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据