2016-03-15 45 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()來解決此問題。

相關問題