ExtJS AJAX TabPanel 选项卡加载事件?
有没有办法将事件监听器添加到 ExtJS v3.3.1 中基于 ajax 的 tabpanel 的加载/更新事件?我需要一个在检索选项卡内容并完全呈现后触发的事件,而不是在选择/激活选项卡并显示加载微调器后立即触发。
我以为我可以在 tabpanel 的 getUpdater() 方法返回的 Ext.Updater 对象上添加此事件,即:
myTabs.getUpdater().on('update', function()
{
console.log('tab loaded');
});
但这似乎不起作用。有什么想法吗?
编辑:这是我的完整实现,以便更容易地看到我正在尝试做的事情:
var myTabs = new Ext.TabPanel(
{
id : 'rec_tabs',
activeTab : 0,
enableTabScroll : true,
padding : 5,
autoWidth : false,
autoHeight : true,
border : false,
plain : true,
defaults : { autoHeight: true },
items :
[
{ title : 'Tab #1', autoLoad : { url : 'tab1_content.php', scripts : true } },
...
]
});
myTabs.render('tab_div');
myTabs.getUpdater().on('update', function()
{
console.log('tab loaded');
});
Is there any way to add an event listener to the load/update event of a ajax based tabpanel in ExtJS v3.3.1? I need an event that fires after the tab content is retrieved and fully rendered, not right after the tab is selected/activated and the loading spinner is displayed.
I thought I would be able to add this event on the Ext.Updater object returned by the tabpanel's getUpdater()
method, i.e.:
myTabs.getUpdater().on('update', function()
{
console.log('tab loaded');
});
But that does not seem to work. Any ideas?
Edit: Here's my full implementation to make it easier to see what I'm trying to do:
var myTabs = new Ext.TabPanel(
{
id : 'rec_tabs',
activeTab : 0,
enableTabScroll : true,
padding : 5,
autoWidth : false,
autoHeight : true,
border : false,
plain : true,
defaults : { autoHeight: true },
items :
[
{ title : 'Tab #1', autoLoad : { url : 'tab1_content.php', scripts : true } },
...
]
});
myTabs.render('tab_div');
myTabs.getUpdater().on('update', function()
{
console.log('tab loaded');
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
终于想通了。我没有意识到 TabPanel 的每个项目的“autoLoad”配置对象的属性实际上只是用作 Ext.Updater.update() 方法的参数。因此,我所要做的就是连同“url”和“scripts”参数一起,将“callback”属性定义为当选项卡内容完成加载到其主体中时要执行的函数,这样就可以了。
Finally figured it out. I hadn't realized that the properties of the "autoLoad" config object for each item of the TabPanel are actually just used as parameters for the Ext.Updater.update() method. So all I had to do was is along with the "url" and "scripts" parameters, is define the "callback" property as a function to be executed when the tab content is finished loading into its body, and its good to go.
你试过这个吗?
Have you tried this?