事件Onclick不起作用

时间:2017-08-04 07:24:15

标签: javascript jquery laravel-5

我有一个数据表,并在该行中按控制器添加一列。 我添加的列有一个应该有onClick事件的按钮。 问题是onClick事件不起作用,什么都不做。但是,没有错误信息。

这是我的代码:

    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);
    }
}

这是我在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);}

有人帮我解决这个问题。 无论如何,谢谢。

0 个答案:

没有答案