10 月 CMS后端小部件事件如何收听/捕捉 onAddItem?

问题描述

如何在 Plugin.PHP 的 boot() 方法中监听/捕获 data-request="formVideo::onAddItem"

在后端,有一个 Repeater 小部件,它有一个按钮 ( https://i.imgur.com/gORjH26.png )。我需要在 Plugin.PHP 的 boot() 方法中捕获此按钮的事件。

解决方法

在这里(https://octobercms.com/forum/post/events-how-to-listencatch-the-onadditem),我收到了解决方案: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);
        }
    }
});

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...