もう一つ初心者に質問します。子が親クラス レベルで定義された関数とデータを参照する方法を複数見つけましたが、どの方法が推奨されるかはわかりません。以下は私が扱っている例ですが、親と子の参照と範囲をよく理解していないため、このトピックは一般的に私にとって重要です。子要素の子から親の関数とデータを参照するにはどうすればよいですか?
いつものように、どんな助けも高く評価されます。
ムハンマド
カリフォルニア州サンノゼ
/******
This is a floating panel with a formpanel inside it, that has an email field and a button to process the email.
When the button is tapped, I want to call the processEmails() function from the button.
******/
Ext.define('myapp.view.ForwardPanel', {
extend : 'Ext.Panel',
xtype : 'forwardPanel',
initialize: function() {
this.callParent(arguments);
var btn = {
xtype: 'button',
ui: 'action',
text: 'Send',
listeners: {
tap: function(){
processEmails(); //<- **How can I reference and call this function?**
// This function is defined at the parent class level
// (indicated at the bottom of the code listing)
}}
};
var form = {
items: [{
xtype: 'fieldset',
instructions: 'Enter multiple emails separated by commas',
title: 'Forward this message.',
items: [ {
xtype: 'emailfield',
name: 'email',
label: 'Email(s)'
},btn] // The button is added to the form here
}]
};
this.add(form);
},
// this is the parent level function I want to call upon button tap.
processEmails: function(){
console.log('Processing email...');
}
});