Full Control Ajax in datatable

var datatable = {
    init: function(){
        var wrap = this;

        d_table = $('#datatable').dataTable( {
            "ajax": function (data, callback, settings) {
                wrap.get_data(function(res){
                    callback(res);
                });
            },
            "order": [[ 4, "desc" ]], 
            "columnDefs": [
                {
                    "targets": [ 12 ],
                    "visible": true,
                    "searchable": false
                }
            ], 
            'language': {
                'search': '資料過濾:'
            }, 
            //Don't use this or event handlers won't be triggered after first page
            //"initComplete": wrap.loaded, 
            "drawCallback": function( settings ) {
                var api = this.api();
                wrap.loaded(settings);
            }
        });
    }, 
    get_params: function(){
        var params = {
            from: $('#search_from').val(), 
            to: $('#search_to').val(), 
            order_type: $('#order_type').val(), 
            order_status: $('#order_status').val(), 
            keyword: $('#keyword').val()
        }

        return params;
    }, 
    get_data: function(callback){
        var wrap = this;
        var params = wrap.get_params();

        $.get(base_url + 'index.php/api/order/all/', params, function(data){
            //console.log(data);
            var result = {data:[]};

            if(typeof data.status == 'undefined'){
                alert(d);
                return result;
            }

            if(data.status == 'fail'){
                alert(data.message);
                return result;
            }

            callback.call(null, data);
        });
    },
    loaded: function(oSettings){
        var wrap = datatable;
        var $table = $('#datatable');

        $table.find('tbody tr').unbind().on( 'click', function () {
            if ( $(this).hasClass('selected') ) {
                $(this).removeClass('selected');
            }else {
                d_table.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }

            //console.log( table.row( this ).data() );
            selected_id = wrap.get_id($(this));
            //console.log(selected_id);
            $('#item_id').val(selected_id);
        });

        $table.find('.edit_item').unbind().on( 'click', function (e) {
            e.preventDefault();
            window.location.href = base_url + 'admin/manager/place_order/?action=update&id=' + selected_id;
        });

        $table.find('.sort_up').unbind().on( 'click', function (e) {
            e.preventDefault();
            var cat_id = $('#cat_id').val();
            wrap.sort(cat_id, selected_id, 'up');
        });

        $table.find('.sort_down').unbind().on( 'click', function (e) {
            e.preventDefault();
            var cat_id = $('#cat_id').val();
            wrap.sort(cat_id, selected_id, 'down');
        });

        $table.find('.view').unbind().on( 'click', function (e) {
            e.preventDefault();
            $('#modal_details').modal();
            details_app.get(selected_id);
        });
    },
    get_id: function($row){
        return $row.find('>td:first').text();
    }, 
    refresh: function(){
        var wrap = this;
        d_table.fnDestroy();
        wrap.init();
    },
    sort: function(cat_id, selected_id, direction){
        var wrap = this;
        var params = {
            cat_id: cat_id, 
            id: selected_id, 
            direction: direction, 
            sort_direction: 'desc'
        }

        $.ajax(base_url + 'index.php/admin/product/sort', {
            type: 'POST', 
            data: params, 
            success: function(data, textStatus, jqXHR){
                //console.log(data.err_code == 0 && err == '');
                //return;
                if(typeof data.err_code == 'undefined'){
                    show_msg('Error', data);
                }else if(data.err_code == 0 && data.err == ''){
                    //console.log(wrap);
                    //window.location.reload();
                    wrap.refresh();
                }else{
                    show_error(data.err_code, data.err);
                }
            },
            error: function(jqXHR, textStatus, errorThrown){
                alert('Error:' + jqXHR.responseText);
            }
        });
    }
}