How to "Delete Participant" without having to refresh (F5) the page?

Asked

Viewed 56 times

0

I have Project here where I work, and when deleting participant, recovered from BD it is deleted, but only some of the page when I give refresh(F5), I would like to know which line of code to insert so that this "participant" disappear as soon as the msg of 'deleted successfully' comes out of the page.

PHP code

<div ng-show="participante.length">

<div class="row">
    <div class="col-md-12">
        <button type="button"
                class="btn btn-danger"
                value="Excluir"
                title="Excluir Participante"
                ng-click="modalExcluirParticipante(participante.selecionados)">
            <span><i class="glyphicon"></i> Excluir Participante(s)</span>
        </button>
    </div>
</div>

Code Angularjs

$scope.modalExcluirParticipante = function (selecionados)
    {
        if( selecionados === undefined || selecionados === null  ){
            alert('Favor informar pelo menos um participante!');
            return false;
        }

        var bSelected = false;
        angular.forEach(selecionados, function (item) {
            if( item ){
                bSelected = item;
            }
        });

        if(!bSelected){
            alert('Favor informar pelo menos um participante!');
            return false;
        }

        $capesModal.open({
            modalOptions: {
                size: 'lg',
                keyboard: false,
                backdrop: 'static',
                controller: ["$scope", "$modalInstance", "$modalStack", "PessoaEventoService",
                    function ($scope, $modalInstance, $modalStack, PessoaEventoService) {
                        "ngInject";

                        $scope.pessoaEvento = {};

                        var itemSelected = [];

                        angular.forEach(selecionados, function(value, key) {
                            if(value){
                                itemSelected.push(key);
                            }

                        });

                        $scope.pessoaEvento.selected = itemSelected;

                       /* $scope.contadorCarecteres = function () {
                            $("textarea").bind("input keyup paste", function (){
                                var maximo = $("#content-countdown").attr('title');
                                var disponivel = maximo - $(this).val().length;
                                if(disponivel < 0) {
                                    var texto = $(this).val().substr(0, maximo); 
                                    $(this).val(texto);
                                    disponivel = 0;
                                }
                                $('.contagem').text(disponivel);
                            });
                        }; */

                        $scope.excluirParticipante = function (data) {

                            if(data.dsObservacao === undefined)
                            {
                                alert('Campo obrigatório.');
                                return false;
                            }
                            PessoaEventoService.excluirPessoaEvento(data)
                                .then(function(dados){
                                    toaster.pop({
                                        type: 'success',
                                        title: 'Participantes',
                                        body: 'Dado excluído com sucesso.',
                                        onHideCallback: function () { 
                                            $modalStack.dismissAll();
                                        }
                                    });                                
                                })
                                .catch(function(err){
                            }); 
                        }  

                    }],
                templateUrl: 'modal/excluir-participante.html',
            }                

        });
    }

1 answer

0

You are performing the treatment of the event in the following excerpt:

PessoaEventoService.excluirPessoaEvento(data)
    .then(function(dados){

        // Tratamento de retorno

        toaster.pop({
            type: 'success',
            title: 'Participantes',
            body: 'Dado excluído com sucesso.',
            onHideCallback: function () { 
                $modalStack.dismissAll();
            }
        });                                
    })
    .catch(function(err){
}); 

Use the same snippet to update your collection being viewed, either by collection reload or by unit deletion.

  • Onosendai, could help me with the code that I should use, as I am a beginner in the programming area, I would like to thank you.

  • The code posted in your question does not provide an example load, @Leufrasio. Take a look at the rest of your code, and try to locate the controller load operation.

Browser other questions tagged

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