Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3800

What does dependent callback do?

$
0
0

Dear Datatables,

I have been reading the documentation in https://editor.datatables.net/reference/api/dependent() and looking at many forum posts about dependent. However, I am still unclear on what the callback in this function does?

editor.dependent( 'position', function ( val, data, callback, e ) {
    $.ajax( {
        url: '/update/position',
        dataType: 'json',
        success: function ( json ) {
            callback( json );
        }
    } );
} );

I saw in datatables.editor.js that it is this function, but I cannot understand it. Any help would be appreciated.

    var update = function (json) {
        if (opts.preUpdate) {
            opts.preUpdate(json);
        }
        // Field specific
        $.each({
            labels: 'label',
            options: 'update',
            values: 'val',
            messages: 'message',
            errors: 'error'
        }, function (jsonProp, fieldFn) {
            if (json[jsonProp]) {
                $.each(json[jsonProp], function (field, val) {
                    that.field(field)[fieldFn](val);
                });
            }
        });
        // Form level
        $.each(['hide', 'show', 'enable', 'disable'], function (i, key) {
            if (json[key]) {
                that[key](json[key], json.animate);
            }
        });
        if (opts.postUpdate) {
            opts.postUpdate(json);
        }
        field.processing(false);
    };

Thanks,

Philip


Viewing all articles
Browse latest Browse all 3800

Trending Articles