scope - ExtJS button handler not working -


my extjs button's handler not invoked after clicking. code looks this.

ext.define('eds.view.selector.container', {     extend: 'ext.form.panel',     alias : 'widget.selectorcontainer',      title: 'selector_v2',     renderto: 'input-div',     layout: 'fit',     height: '100%',      items: [             {                 xtype: 'tabpanel',                 defaults: {                     bodypadding: 10                 },             }     ],     buttons: [         {             text: 'reset',             handler: function(){                 console.log("reset");                 this.up('form').getform().reset();             }         },         {             text: 'add constrain',             handler: this.addconstrain,         }     ],      /*      * logic button "add constrain"      *       * adds entry constrain list describing person, cost center or application      */     addconstrain: function(button, event){         console.log('add_to_constrain clicked');     } }); 

originally 'selectorcontainer' put diretly in app.js. extracted stand-alone view. before extraction, works perfect not working.

btw, i've 2 buttons , first "reset" works fine. i'm wondering if there's wrong "this.addconstrain" related scoping.

the proper way design class this. apply config settings object before callparent.

ext.define('eds.view.selector.container', {     extend: 'ext.form.panel',     alias : 'widget.selectorcontainer',      title: 'selector_v2',     renderto: 'input-div',     layout: 'fit',     height: '100%',      initcomponent: function() {          ext.applyif(this, {             items: [                {                    xtype: 'tabpanel',                    defaults: {                       bodypadding: 10                    }                }            ],            buttons: [                {                   text: 'reset',                   scope: this,                 // <--- scope form panel                   handler: function(){                      console.log("reset");                      this.getform().reset();                   }                },                {                    text: 'add constrain',                    scope : this,               // <--- scope form panel                    handler: this.addconstrain                }            ]        });         this.callparent(arguments);    }   /*    * logic button "add constrain"    *     * adds entry constrain list describing person, cost center or      application    */    addconstrain: function(button, event){       console.log('add_to_constrain clicked');    } }); 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

visual studio - TFS will not accept changes I've made to a Java project -