Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用onClick事件扩展Aviarc容器小部件_Javascript_Aviarc - Fatal编程技术网

Javascript 使用onClick事件扩展Aviarc容器小部件

Javascript 使用onClick事件扩展Aviarc容器小部件,javascript,aviarc,Javascript,Aviarc,我在屏幕布局中使用了一些容器小部件。我需要扩展容器,使其具有“onClick”事件,以便我可以按照以下方式执行操作: <screen> <container name="customer-list" ..> <!-- some content over here --> </container> <action:behaviors> <action:when widget-

我在屏幕布局中使用了一些容器小部件。我需要扩展容器,使其具有“onClick”事件,以便我可以按照以下方式执行操作:

<screen>
    <container name="customer-list" ..>
        <!-- some content over here -->
    </container>

    <action:behaviors>
        <action:when widget-event="customer-list.onClick">
            <!-- some actions here -->
        </action:when>
    </action:behaviors>
</screen>

要添加对onClick事件的支持,您需要在小部件中添加以下内容:

WidgetName = function() {
    this.onClick = new Toronto.client.Event("WidgetName onClick");
};
在小部件的构造函数中声明事件:

WidgetName = function() {
    this.onClick = new Toronto.client.Event("WidgetName onClick");
};
然后在启动方法中添加以下行:

widgetContext.addManagedDOMEvent(this.getContainerElement(), "onclick", this._onClickHandler, this, "WidgetName onClick binding");
剩下唯一要实现的就是实际的处理程序:

, _onClickHandler: function() {
    this.onClick.fireEvent({
        widget: this
    });
}
其思想是向小部件添加事件,将事件绑定到DOM节点,并在处理程序中扩展fireEvent的属性对象,以包含屏幕所需的所有相关细节