2016-07-27 6 views
0

Ich bin neue Extjs Benutzer Ich habe Controller in der Navigation definiert, aber nicht funktioniert. Bitte helfen Sie.Extjs Controller definieren innerhalb Navigation

Ext.define('MyApp.controller.Navigation', { 
    extend: 'Ext.app.Controller', 
    alias: 'widget.navigationController', 

    views: ['Navigation'], 


    refs : [{ 
     ref: 'navigationView', 
     selector: 'navigation' 
    }], 


    init: function(application){ 
     console.log('controller init'); 
     this.control({ 
      'navigation': { 
       'golocale': this.goLocale, 
       'gobrand': this.goBrand, 
       'gosize': this.goSize, 
       'goarticle': this.goArticle, 
       'gogender': this.goGender, 
       'goprofile': this.goProfile, 
       scope: this 
      } 
     }); 
    }, 


    goLocale: function(link){ 
     console.log('locale clicked'); 
     console.dir(link); 
    }, 


    goBrand: function(link){ 
     console.log('brand clicked'); 
     // Also tried: 
     // var viewport = this.getView('Viewport').create(); 
     var viewport = link.up('viewport'); 
     console.dir(viewport); 
    }, 

Konsole Fehler unten

MyApp.controller.Navigation.addListener(): The specified callback function is undefined 
+1

Wo sind die anderen Methoden? 'goSize',' goArticle' etc? Das ist wahrscheinlich der Grund für die Ausnahme. –

Antwort

0

Sie bieten auf Ihre Funktion "Kontrolle" eines Objekts.

Innerhalb dieses Objekts zeigt this auf das Objekt, nicht mehr auf den Controller. Bitte versuchen Sie

init: function(application){ 
    console.log('controller init'); 
    var me = this; // "me" is scope to controller 
    this.control({ 
     'navigation': { 
      'golocale': me.goLocale, 
      'gobrand': me.goBrand, 
      'gosize': me.goSize, 
      'goarticle': me.goArticle, 
      'gogender': me.goGender, 
      'goprofile': me.goProfile, 
      scope: me 
     } 
    });