vendredi 4 août 2017

event Onclick doesn't work

I have a data tables and add a column by controller in that row. the column that I was add has a button that should has an event On Click. the issue is the event On click doesn't work and does nothing. But, there is nothing error message.

this is my code:

    public function show(Request $request)
    {
    if($request->ajax()){
        $searchs = $request->get('search');
        $search = $searchs['value'];
        \DB::statement(\DB::raw('set @nomor = 0'));

        $index = DB::table('tb_jabatan_karyawan')
                ->leftJoin('tb_jabatan','tb_jabatan.id','=','tb_jabatan_karyawan.id_jabatan')
                ->leftJoin('tb_karyawan','tb_karyawan.id','=','tb_jabatan_karyawan.id_karyawan')
                ->leftJoin('tb_gaji_pokok','tb_gaji_pokok.karyawan_id','=','tb_jabatan_karyawan.id_karyawan')
                ->select([
                    \DB::raw('@nomor := @nomor + 1 as no'),
                    //'tb_gaji_pokok.id as id_gaji_pokok',
                    'tb_jabatan_karyawan.id as id',
                    'tb_jabatan_karyawan.id_karyawan as id_karyawan',
                    'tb_jabatan_karyawan.id_jabatan as id_jabatan',
                    'tb_karyawan.nama as nama',
                    'tb_karyawan.status_karyawan as status',
                    'tb_jabatan.nama_jabatan as jabatan',
                    'tb_gaji_pokok.jumlah_gapok as gaji_pokok'
                    ]);

        return Datatables::of($index)
            ->edit_column('no', function($index){
                return '<center>'.$index->no.'</center>';
            })
            ->edit_column('nama', function($index){
                return ucwords($index->nama);
            })
            ->edit_column('status', function($index){
                return ucwords($index->status);
            })
            ->filter(function ($query) use ($request){
                if ($request->get('search')['value']){
                  $query->where('nama', 'like', "%{$request->get('search')['value']}%");
                }
            })//here is the problem
            ->addColumn('action', function($index){
                $tag = "<center><a class='btn btn-info btn-xs onclick=atur('".$index->id_karyawan."')><i class='fa fa-pencil'></i> Atur Gaji</a></center>";
                return $tag;

            })
        ->make(true);
    }
}

in this is my function in ajax

    function atur(id){var infoModal = $('#gajipokok');

    if(id) {
            $.ajax({
                url: path+'/aturgaji/'+id,
                type: "GET",
                dataType: "json",
                success:function(data) {

htmlData = '<h3>Nama Karyawan  '+data.karyawan.nama+'</h3>';

                        infoModal.find('.modal-body').html(htmlData);

                        modalGajiShow();
                        //$('#jalurdetail').append('<h2>'+key.nama+'</h2>');
                    //});

                }
            });
        }
         else {
                modalGajiHide();
                notify(0, 'Something when wrong');
                }
            alert(2);}

Please someone help me to fix this. thanks anyway.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wcNmmH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire