Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with inheritance
    primarykey
    data
    text
    <p>I have created 3 classes as following</p> <ol> <li>Ext.mine.TextParent - Inherting from Textfield</li> <li>Ext.mine.child.TextChildA - Inherting from Ext.mine.TextParent</li> <li>Ext.mine.child.TextChildB - Inherting from Ext.mine.TextParent</li> </ol> <p>This way, Child A and Child B classes are siblings as both are inherting from the Parent class.</p> <p>I have added a new config property to parent class as testConfig with defalult value being <code>{}</code>.</p> <p>In the <code>initComponent</code> of Child A class, I have assigned a new key:value to this testConfig as - <code>me.testConfig.childAKey='Child A Value';</code></p> <p>Now, there is a form which is using all the three textfields and in the afterrender of the textChildB type, I am printing the value of its testConfig.</p> <p>As the value of testConfig is not modified in Child B, thus, it is expected that this should print blank object (as the default value in parent of this testConfig is blank object).</p> <p>But it actually prints the values from Child A.</p> <p>Child A and Child B are siblings, thus, how can the value from Child A come to Child B?</p> <p>Could someone please guide that what could be the reason behind this?</p> <p>Below is the test case:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Inheritance Test&lt;/title&gt; &lt;link rel='stylesheet' href='resources/extjs/resources/css/ext-all.css' /&gt; &lt;script type='text/javascript' src='resources/extjs/ext-all-dev.js'&gt;&lt;/script&gt; &lt;script type='text/javascript'&gt; //Defining the Parent below Ext.define('Ext.mine.TextParent', { extend: 'Ext.form.field.Text', alias: 'widget.textParent', testConfig:{} }); //Defining the Child A below Ext.define('Ext.mine.child.TextChildA', { extend: 'Ext.mine.TextParent', alias: 'widget.textChildA', initComponent:function(){ var me = this; me.testConfig.childAKey = 'Child A Value';//Adding the key value to Child A me.callParent(); } }); //Defining the Child B below Ext.define('Ext.mine.child.TextChildB', { extend: 'Ext.mine.TextParent', alias: 'widget.textChildB' }); &lt;/script&gt; &lt;script type='text/javascript'&gt; Ext.onReady(function(){ Ext.create('Ext.form.Panel', { title: 'Basic Form', renderTo: Ext.getBody(), width: 350, url: 'save-form.php', items: [{ xtype: 'textParent',//Creating field for Parent fieldLabel: 'Text Parent', flex:1 },{ xtype: 'textChildA',//Creating field for Child A fieldLabel: 'Text Child A', flex:1 },{ xtype: 'textChildB',//Creating field for Child B fieldLabel: 'Text Child B', flex:1, listeners:{ afterrender:function(){ /* **Printing to console the value of testConfig for Child B **Instead of giving a blank object, it is giving the values of Child A - childKey:Child A Value **How the value from a sibling got associated with another one? */ console.log(this.testConfig); } } }] }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload