2012-07-18 20 views
6

Próbowałem przetestować skrypt napisany na konsoli firebug i uważam, że skrypt jest dość prosty. A kiedy uruchomiłem skrypt, otrzymałem ten błąd me.dockedItems jest niezdefiniowany. Oto kod i uruchomić z konsoli firebug Firefoksa:me.dockedItems error in ExtJS

Ext.create('Ext.window.Window',{ 
    title : 'Login', 
    width : 400, 
    height : 500, 
    initComponent : function() { 
     var me = this; 

     var usernameField = Ext.create('Ext.form.field.Text',{ 
      fieldLabel : 'Net ID', 
      allowBlank : false, 
      labelWidth : 150, 
      width : 150, 
      emptyText : 'Net ID' 
     }); 

     var passField = Ext.create('Ext.form.field.Text',{ 
      fieldLabel : 'Password', 
      allowBlank : false, 
      labelWidth : 150, 
      width : 150, 
      emptyText : 'Pass' 
     }); 

     this.items = [usernameField,passField]; 
     this.callParent(arguments); 
    } 
}).show(); 

Doceniam Twojej pomocy, aby znaleźć to, co jest nie tak z kodem

Odpowiedz

5

Nie zastępują initComponent podczas tworzenia instancji.

Ext.create('Ext.window.Window', { 
    title: 'Login', 
    width: 400, 
    height: 500, 
    items: [{ 
     xtype: 'textfield', 
     fieldLabel: 'Net ID', 
     allowBlank: false, 
     labelWidth: 150, 
     width: 150, 
     emptyText: 'Net ID' 
    }, { 
     xtype: 'textfield', 
     fieldLabel: 'Password', 
     allowBlank: false, 
     labelWidth: 150, 
     width: 150, 
     emptyText: 'Pass' 
    }] 
}).show(); 
8

mam ten błąd, gdy robi

Ext.define('blah', { 

    initComponent: function(){ 
     //do stuff 
    } 
}); 

Okazuje się to pytanie sortof wskazując właściwy kierunek, ale można również uzyskać ten tajemniczy błąd, jeśli nie nazywamy

this.callParent(arguments); 

na końcu initComponent. Przydatny!