다른 초보자 용 질문을하겠습니다. 하위 클래스가 상위 클래스 수준에서 정의 된 함수 및 데이터를 참조하는 여러 가지 방법이 있지만 권장되는 방법이 무엇인지 잘 모르겠습니다. 아래는 제가 다루고있는 예입니다. 그러나이 주제는 부모님과 아이들의 참조와 범위를 잘 이해하지 못하기 때문에 일반적으로 중요합니다. 하위 요소의 하위에서 부모의 함수 및 데이터를 참조하려면 어떻게해야합니까?Sencha Touch 2 - 부모 요소에서 하위 요소를 참조하는 올바른 방법?
언제나처럼, 모든 도움을 주실 수 있습니다.
모하마드
산호세, 캘리포니아
/******
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...');
}
});
예, 이것이 부모 참조를 전달하는 편리한 방법이라고 생각합니다. 감사. – Mohammad