Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 139893

jQuery selector won't work with Datatables

$
0
0

hey guys i have a problem with Datatable plugin the problem is that i can't select a chackbox in the action column to convert checkbox into toggles (bootstrap-toggle) it was working before but when i use the serverside of datatable and declare the checkbox in the controller nothing works (Sorry for my english ) please help!! this is the controller code

return DataTables::of($participant)
        ->addColumn('action',function($participant){
            $route = route('admin.participant.presence',$participant);

            return '<form action="'.$route.'" method="PATCH">
            <input type="hidden" name="presence" value="0">
            <input type="checkbox" class="participation" onchange="this.form.submit()"'.isChecked($participant).' name="presence" value="1">
            </form>';
        })->make(true);

and here's the js code in the view and I think the problem comes from here

<script>
        $(document).ready( function(){
            var id = {{request()->route('id')}};
        $('#table').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": "/admin/evenment/event/participant/ajaxdatatable/"+id,
        "columns":[
            {"data": "adherent_id"},
            {"data": "nom_participant"},
            {"data": "prenom_participant"},
            {"data": "fonction"},
            {"data": "action"},
        ]
    });
    $('.participation').bootstrapToggle({
        on: 'Oui',
        off: 'Non',
        onstyle: 'success',
        offstyle: 'danger',
        width: '70'
    });
    });

    </script>

Viewing all articles
Browse latest Browse all 139893

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>