Teste

teste

quinta-feira, 8 de dezembro de 2016

Bootstrap Form Modal

Boa Tarde a todos.

Depois de muistos testes, criei uma regra para NÃO fechar (hide) o Formulário Modal se existir erros.

$('#form').on('submit', function () {
    $.ajax({
        type: $(this).attr('method'),        
        url: this.action,        
        data: $(this).serialize(),        
        context: this,        
        async: false,        
        success: function (data) {
            var erro = $(data).find("div.has-error");
            if(erro.length > 0) {
                $('#modal_form').modal('hide');
                $('#div_form_modal').html(data); 
                $('#modal_form').modal('show');  
                return false;            
            }
            $('#modal_form').modal('hide');        
        }
    });    
    return false;
});

Nenhum comentário: