在 Ext JS 中将点击事件绑定到 Tab

发布于 2024-11-07 09:55:54 字数 1035 浏览 0 评论 0原文

再次问好,SO。

我正忙于一个几乎全部使用 ExtJS 进行前端工作的项目。我使用的是 4.0.0 版本,假设这是有必要了解的。我有一些代码如下:

panel = Ext.create("Ext.panel.Panel",{
        //initializing stuffs
})

其中一些现在

 tabs = Ext.create("Ext.tab.Panel", {
        //initialize config
        items: [
               //the panels
        ]
  })

我的大问题是,我需要能够将事件绑定到实际的选项卡。我知道能够将事件绑定到选项卡面板和选项卡栏,但我需要实际将单击事件绑定到面板中的选项卡之一。我尝试了类似的操作:

panel = Ext.create("Ext.panel.Panel", {
        //initializing stuffs
        listeners: {
                 click: {
                        fn: function() {
                            console.log("in click listener for panel")
                        }
                  }
         }
 })

但是,问题是,根据我所知,它绑定到实际面板本身,而不是绑定到选项卡栏中的选项卡。有趣的是,就功能而言,它实际上甚至没有绑定到实际面板,因为我从未看到控制台日志信息。

无论如何,这里有人知道如何将事件直接绑定到选项卡吗?或者甚至如何直接访问选项卡?我一直在筛选 ExtJS API 文档,但我仍然找不到任何东西,所以,如果这里有人能提供帮助,那就太棒了! :D

只是为了澄清,我并不是试图挂钩选项卡更改。我试图挂钩单击选项卡的实际单击事件,因为我将检查是否单击了鼠标中键,以便我可以关闭选项卡(如果是)。

Aloha again, SO.

I'm busy working on a project that is pretty much all ExtJS for the frontend work. I'm using version 4.0.0, presuming that is something necessary to know. I've got some code along the following:

panel = Ext.create("Ext.panel.Panel",{
        //initializing stuffs
})

A few of those then

 tabs = Ext.create("Ext.tab.Panel", {
        //initialize config
        items: [
               //the panels
        ]
  })

Now my big problem here is, I need to be able to bind an event to the actual tabs. I'm aware of being able to bind events to the tab panel and tab bar, but I need to actually bind the click event to one of the tabs in the panel. I tried something along the lines of this:

panel = Ext.create("Ext.panel.Panel", {
        //initializing stuffs
        listeners: {
                 click: {
                        fn: function() {
                            console.log("in click listener for panel")
                        }
                  }
         }
 })

However, the problem is, based on what I can tell, that binds to the actual panel itself, and not to the tab up in the tab bar. On an interesting side note, it actually doesn't even bind to the actual panel, as far as functionality is concerned, because I never see that console log information.

In any case, would any of you here happen to know how to bind events directly to the tabs? Or even how to get access to the tabs directly? I've been sifting through the ExtJS API docs, but I still can't find anything, so, it'd be awesome if someone here could help! :D

Just to make it clear, I'm not trying to hook into the tab changing. I'm trying to hook into the actual click event of clicking the tab, because I am going to be checking if it is the middle mouse button being clicked so I can close the tab if it is.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼藏柔 2024-11-14 09:55:54

我把它放在 ExtJS 3 中选项卡面板内的选项卡上。类似的东西应该可以在 4 中使用。

listeners: {
    activate: function() {
        var me = this;
        Ext.fly(this.ownerCt.getTabEl(this)).on({
            click: function() {
                me.loadProducts();
            }
        });
    },
    single: true
},

loadProducts: function() {
    this.load({
    url: 'products.jsp',
    params: {
        caseID: window.caseID
    },
    scripts: true
});

I put this on a tab inside a tab panel in ExtJS 3. Something similar should work in 4.

listeners: {
    activate: function() {
        var me = this;
        Ext.fly(this.ownerCt.getTabEl(this)).on({
            click: function() {
                me.loadProducts();
            }
        });
    },
    single: true
},

loadProducts: function() {
    this.load({
    url: 'products.jsp',
    params: {
        caseID: window.caseID
    },
    scripts: true
});
知足的幸福 2024-11-14 09:55:54

您可以将侦听器添加到 TabPanel 本身监听 beforetabchange 和/或 tabchange

You can add listeners to TabPanel itself that listen to beforetabchange and/or tabchange

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文