Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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 ExtJS arrowHandler需要引用它所属的splitbutton_Javascript_Extjs - Fatal编程技术网

Javascript ExtJS arrowHandler需要引用它所属的splitbutton

Javascript ExtJS arrowHandler需要引用它所属的splitbutton,javascript,extjs,Javascript,Extjs,在下面的代码中,Ext.getCmp不起作用,因为它们在被调用时没有完全定义。我怎样才能抓住这两样东西 另外,还有另一部分代码不断地按list.menu.buttons,所以我需要在单击箭头时才将它们添加到项目中 xtype: "splitbutton", id: "list", enableToggle: true, arrowHandler: (function () { var library = Ext.getCmp("library");

在下面的代码中,Ext.getCmp不起作用,因为它们在被调用时没有完全定义。我怎样才能抓住这两样东西

另外,还有另一部分代码不断地按list.menu.buttons,所以我需要在单击箭头时才将它们添加到项目中

xtype: "splitbutton",
id: "list",
enableToggle: true,
arrowHandler: (function () {
                var library = Ext.getCmp("library");
                var buttons = Ext.getCmp("list").menu.buttons;
            function btn(num) {
                var image = new Image;
                image.src = buttons[num].dataURL;
                this.xtype = "button";
                this.height = 50;
                this.width = 50;
                this.icon = image;
                this.num = num;
                this.handler = function (btn) {
                    btn.up("button").fireEvent("selected", this.num);
                };
            }
            for (var i = 1; i <= 1; i++)
                library.push(new btn(i));
        })(),
menu: {
    plain: true,
    buttons: [],                            
    items: [
        {
            xtype: "ribbon_gallery",
            columns: 3,
            title: "Recent",
            id: "recent",
            items: []
        },
        {
            xtype: "ribbon_gallery",
            columns: 3,
            title: "Library",
            id: "library",
            itemId: "library",
            items: []
        }
    ]
}

问题是您已经为arrowHandler配置指定了一个函数

你需要一个正常的函数

  arrowHandler: (function() {...})()
  arrowHandler: function() {...}