mercredi 29 janvier 2020

Pagination with multiple checkbox and pagination in laravel

I have a modal in the page for create new role in my system and this modal list all permissions to the role. My problem is this: This modal have a table with multiple checkboxes and pagination, but when I go to page 2, 3, 4... The checkboxes lost the selection. I try any things to resolve this problem, but i cant. Modal checkbox list

The cod of pagination

 $(document).on('click', '.pagination a', function (e) {
        e.preventDefault();

        var url = $(this).attr('href');

        $('#modal-content').load(url + " #content-result");
    });

The modal

<div class="modal fade" id="add-permissions" tabindex="-1" role="dialog" aria-labelledby="Adicionar permissões"
    aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5><b>Adicionar Permissões</b></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <input type="text" name="modal-search" class="form-control" id="search-1"
                            placeholder="Procurar pelo nome">
                    </div>
                </div>

                <hr>

                <div id="modal-content">
                    <div id="content-result">
                        <div class="row">
                            <div class="col-md-12">
                                <table class="table table-bordered table-sm" id="table-search-1">
                                    <thead>
                                        <tr>
                                            <th>Nome</th>
                                            <th>Rótulo</th>
                                            <th>Selecionar</th>
                                        </tr>
                                    </thead>

                                    <tbody>
                                        @forelse ($permissions as $key => $permission)
                                        <tr>
                                            <td></td>
                                            <td></td>
                                            <td>
                                                <input type="checkbox" class="teste-add" name="addPermissions[]" id="" value="">
                                            </td>
                                        </tr>
                                        @empty
                                        <tr>
                                            <td colspan="2" class="text-center"><b>Nenhuma permissão encontrada!</b>
                                            </td>
                                        </tr>
                                        @endforelse
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <p>{!! $permissions->links() !!}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal-footer justify-content-between">
                <div class="row">
                    <div class="col-md-12">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Ok</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



Aucun commentaire:

Enregistrer un commentaire