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

0

I have Project here where I work, and when deleting participant, retrieved from DB it is deleted, but only disappears from the page when I refresh (F5), I would like to know which line of code to insert so that this "participant" disappears as soon as the msg of 'successfully deleted' page sum.

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>

Angular Code

$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',
            }                

        });
    }
    
asked by anonymous 21.03.2017 / 14:34

1 answer

0

You are performing the event handling in the following section:

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 by viewing, or by reloading the collection or by unit deletion.

    
21.03.2017 / 14:48