【问题标题】:October CMS. Backend Widgets. Events. How to listen/catch the onAddItem?十月 CMS。后端小部件。事件。如何收听/捕捉 onAddItem?
【发布时间】:2021-05-17 16:32:03
【问题描述】:

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

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

【问题讨论】:

    标签: events octobercms octobercms-backend octobercms-widgets


    【解决方案1】:

    在这里(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);
            }
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2012-09-12
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-28
      相关资源
      最近更新 更多