Normal Button Onclick event - Uncaught TypeError: Cannot read property 'success' of undefined at Object.value [as successTest] (atkjs-ui.min.js:1)


i created a button with the statment by using the example. after the clicking button i want see only a messge in the frontend.

$ls_we_btn = $app->add(['Button', 'Wareneingang Buchen', 'blue', 'icon'=>'caret square up']);
$ls_we_btn->on('click', function() use($table){ return 'ok';
                                                    }, [new \atk4\ui\jsReload($table)]);

but i get the error:

Uncaught TypeError: Cannot read property 'success' of undefined

Can someone give me the small tip ?

Thx a lot


Hi Z.Peter

I think you’re mixing something up.

function you pass to on() as 2rd argument supposed to return string or jsCallback. you are returning ‘ok’ which is fine. You also can return “new jsReload()” which is a jsCallback.

Third argument to on() can specify arguments which will be passed INTO a callback when invoked. Normally you could use jsExpression here to fetch value of a field or something else, e.g. $form_field->jsInput()->val();

Try moving “new …jsReload” into the body of your function() { … } and it should work.