如何data-request="formVideo::onAddItem"
在 Plugin.php 的 boot() 方法中收听/捕捉?
在后端,有一个 Repeater 小部件,它有一个按钮 ( https://i.imgur.com/gORjH26.png )。我需要在 Plugin.php 的 boot() 方法中捕获此按钮的事件。
如何data-request="formVideo::onAddItem"
在 Plugin.php 的 boot() 方法中收听/捕捉?
在后端,有一个 Repeater 小部件,它有一个按钮 ( https://i.imgur.com/gORjH26.png )。我需要在 Plugin.php 的 boot() 方法中捕获此按钮的事件。
Here ( https://octobercms.com/forum/post/events-how-to-listencatch-the-onadditem ), I received the solution: https://octobercms.com/docs/api/backend/ajax/beforerunhandler
Event::listen('backend.ajax.beforeRunHandler', function ((\Backend\Classes\Controller) $controller, (string) $handler) {
if (strpos($handler, '::')) {
list($componentAlias, $handlerName) = explode('::', $handler);
if ($componentAlias === $this->getBackendWidgetAlias()) {
return $this->backendControllerProxy->runAjaxHandler($handler);
}
}
});