在 Ext JS 中将点击事件绑定到 Tab
再次问好,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我把它放在 ExtJS 3 中选项卡面板内的选项卡上。类似的东西应该可以在 4 中使用。
I put this on a tab inside a tab panel in ExtJS 3. Something similar should work in 4.
您可以将侦听器添加到 TabPanel 本身监听
beforetabchange
和/或tabchange
You can add listeners to TabPanel itself that listen to
beforetabchange
and/ortabchange