How to delete a Dialog from the data recording process

Asked

Viewed 24 times

1

I have a legacy system of register control and the same is working perfectly in what concerns the recording of data in the database, but I’m trying to adapt the same and I’m not getting. The current script shows a dialog further, I need only show only the dialog which informs if the record has been entered successfully or if an error has occurred, I would like to delete the first one that is displayed.

I’m using this project:Bootstrap 3 Dialog

I already have that:

    function DlgInserirFase() {
    //Dialog de inserção de dados   

    BootstrapDialog.show({
        //title: 'Fase',
        // message: $('<div id="divNotas"></div>').load('frmMural.html'),
        closable: false,

        buttons: [{

            //icon: 'glyphicon glyphicon-send',
            //label: 'Gravar',
            //cssClass: 'btn-primary',
            //autospin: true,

            action: function(dialogRef){

                //Chama o validate do formulário
                // $('#frmFase').validate();
                //if ($('#frmFase').valid() == true) {
                    //dialogRef.enableButtons(false);
                    // dialogRef.setClosable(false);

                    var params = {
                        Operacao:   'Inserir',
                        dTipoFase:  $('#dTipoFase').val(),
                        dData:      $('#dData').val(),
                        dHora:      $('#dHora').val(),
                        dDescricao: $('#dDescricao').val(),
                        IdContrato: $("input[name=IdContrato]").val(),                          
                    };

                    // GravaFase(params);

                    $.post(
                        'ProcessoFase.php',
                        params,
                        function( json, textStatus, jQxhr ){
                            if (json.status != "ERRO") {
                                var dialogInstance = BootstrapDialog.show({
                                    title: 'SUCESSO',
                                    type: BootstrapDialog.TYPE_SUCCESS,
                                    message: json.msg,
                                    closable: false,
                                    buttons: [
                                        {
                                            label: 'Fechar',
                                            cssClass: 'btn-success',
                                            action: function(dialogRef){
                                                dialogRef.close();
                                                location.reload();
                                            }
                                        }
                                    ]   
                                }); 
                            } else {    

                                var dialogInstance = BootstrapDialog.show({
                                    title: 'ERRO',
                                    type: BootstrapDialog.TYPE_DANGER,
                                    message: json.msg,
                                    closable: false,
                                    buttons: [
                                        {
                                            label: 'Fechar',
                                            cssClass: 'btn-danger',
                                            action: function(dialogRef){
                                                dialogRef.close();
                                                // location.reload();
                                            }
                                        }
                                    ]                                       
                                }); 
                            }
                        },
                        'json'
                    )
                    .fail(function( jqXhr, textStatus, errorThrown ){
                        try {
                            var json = $.parseJSON(jqXHR.responseText);
                            var dialogInstance = BootstrapDialog.show({
                                title: 'ERRO',
                                type: BootstrapDialog.TYPE_DANGER,
                                message: json.msg
                            }); 
                        } catch(e) { 
                            var dialogInstance = BootstrapDialog.show({
                                title: 'ERRO',
                                type: BootstrapDialog.TYPE_DANGER,
                                message: json.msg
                            }); 
                        }
                    });

                    dialogRef.close();
                //}
            }
        },

        {
            label: 'Cancelar',
            cssClass: 'btn-danger',
            action: function(dialogRef){
                dialogRef.close();
            }
        }]
    });
}

1 answer

0


Eventually I managed to solve, I was with problems in my console.log and I could not see the error messages, I solved this problem and with a step-by-step I changed the way the registration was being made, it was like this:

    function DlgInserirFase() {
    //Dialog de inserção de dados   
    var params = {
        Operacao:   'Inserir',
        dTipoFase:  $('#dTipoFase').val(),
        dData:      $('#dData').val(),
        dHora:      $('#dHora').val(),
        dDescricao: $('#dDescricao').val(),
        IdContrato: $("input[name=IdContrato]").val(),                          
    };

    // GravaFase(params);

    $.post(
        'ProcessoFase.php',
        params,
        function( json, textStatus, jQxhr ){
            if (json.status != "ERRO") {
                var dialogInstance = BootstrapDialog.show({
                    title: 'SUCESSO',
                    type: BootstrapDialog.TYPE_SUCCESS,
                    message: json.msg,
                    closable: false,
                    buttons: [
                        {
                            label: 'Fechar',
                            cssClass: 'btn-success',
                            action: function(dialogRef){
                                dialogRef.close();
                                location.reload();
                            }
                        }
                    ]   
                }); 
            } else {    

                var dialogInstance = BootstrapDialog.show({
                    title: 'ERRO',
                    type: BootstrapDialog.TYPE_DANGER,
                    message: json.msg,
                    closable: false,
                    buttons: [
                        {
                            label: 'Fechar',
                            cssClass: 'btn-danger',
                            action: function(dialogRef){
                                dialogRef.close();
                                // location.reload();
                            }
                        }
                    ]                                       
                }); 
            }
        },
        'json'
    )
    .fail(function( jqXhr, textStatus, errorThrown ){
        try {
            var json = $.parseJSON(jqXHR.responseText);
            var dialogInstance = BootstrapDialog.show({
                title: 'ERRO',
                type: BootstrapDialog.TYPE_DANGER,
                message: json.msg
            }); 
        } catch(e) { 
            var dialogInstance = BootstrapDialog.show({
                title: 'ERRO',
                type: BootstrapDialog.TYPE_DANGER,
                message: json.msg
            }); 
        }
    });



}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.