2016-03-15 62 views
0

我有三种形式ProfileForm.js,ProfileTab.js和ItemTab.js。 ProfileTab正在从Items.js中调用(扩展类)。以形式调用函数

这里是一个ProfileTab.js

Example.Portal.ProfilesTab = Ext.extend(Example.Portal.ItemTab, { 
    initComponent: function() { 
     var me = this; 
     Ext.apply(this, { 
      gridConfig: { 
       title: 'Profile Templates', 
       width: 260, 
       xtype: 'example.portal.profilesgrid' 
      }, 
      panelConfig: { 
       title: 'Profile Template', 
       xtype: 'example.portal.profileform' 
      } 
     }); 
     Example.Portal.ProfilesTab.superclass.initComponent.apply(this, arguments); 
    } 
}); 

Ext.reg('example.portal.profilestab', Example.Portal.ProfilesTab); 

ProfileForm用作 '的xtype'。我试图在ItemTab.js中添加一个可以在ProfileForm.js中使用的函数。

我已经尝试在ItemTab.js中添加一个函数,但我无法在ProfileForm中访问它。

任何帮助,将不胜感激。我处于学习阶段,请不要降级这个问题。

+0

你试过'this.some_func()'?应该在那里。也许你的'this'指向错误的东西,打印出来看看你是否在正确的范围内。 – serg

+0

是的,我已经这样做了。我可以在ItemTab和ProfileTab中访问this.some_func(),但不能在ProfileForm – ashhad

+0

中,因此ProfileForm不会继承任何东西?那么为什么你觉得你应该能够访问它的一些不相关的代码,或者我错过了一些东西。 xtype并不意味着什么,它可能是'xtype:button',按钮将无法访问其他文件。 – serg

回答

0

对于那些想要类似的人,我通过在ItemTab.js中添加侦听器事件并在ProfileForm.js中使用了fireEvent()来解决此问题。