Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback function seem to only work if params are passed - possible bug? #87

Open
alanapplyby opened this issue Sep 23, 2021 · 0 comments

Comments

@alanapplyby
Copy link

alanapplyby commented Sep 23, 2021

Isn't there a small bug in the construct callback function of the plugin:

public function __construct(string $name, array $args = [])
    {
        if (empty($args)) {
            $code = $name;
        } else {
            $code = 'function () { ';
            foreach ($args as $a) {
                $arg = json_encode($a);
                $code .= "Array.prototype.push.call(arguments, {$arg});";
            }
            $code .= "return {$name}.apply(this, arguments); }";
        }

        $this->setHash($code);
    }

Seems that this forces any callback function to use parameters, otherwise the construct just returns the hash of $name.

In my example I have a callback function that doesn't require any paranmters:

dt.render.foo = function (data, type, full, meta) {
        ....
        return foobar;
    }

$columns[7]['render'] = $this->DataTables->callback('foo');

This will not call the callback function so I have to do something like this to force it to work:

$columns[7]['render'] = $this->DataTables->callback('foo', [false]);

Or did I mis-understand something about how this should work?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant