0

I am building an application and I am trying to keep it object oriented. The issue is that the alert box doesn't appear when the button is clicked. I believe it is an issue with the scope of the button. It could also be related to the way i am building my app. It is based off of an example provided by Sencha. I have searched, and tried many things, but I haven't come up with a solution. Here is my code:

Ext.require([
    'Ext.grid.*',
    'Ext.panel.*',  
    'Ext.msg.*'     
]);
Ext.Loader.onReady(function() {
Ext.define('App.SimplePanel', {
        extend: 'Ext.Panel',
        alias: 'widget.SimplePanel',    
        width: 100,
        height: 50, 

        initComponent: function() {     
        this.buttons = [{
            text: 'Trigger Alert',  
            scope: this,
            hander: function(){                 
                Ext.Msg.alert('Title', 'TestAlert');
            }
        }];         
        this.callParent();
        }   
    });
}, false);
Ext.onReady(function() {
    // create an instance of the app
    var simplePanel = new App.SimplePanel({
        renderTo: document.body,        
    }); 
});

1 Answer 1

1

The issue is property should be called handler not hander

this.buttons = [{
  text: 'Trigger Alert',  
  scope: this,
  handler: function(){                 
    Ext.Msg.alert('Title', 'TestAlert');
  }
}];
Sign up to request clarification or add additional context in comments.

2 Comments

Now I feel dumb. I've spent all morning trying to figure this out. I guess I need more coffee.
Don't worry. Sooner or later you'l find yourself in situation, when you discover your ExtJS code has been working fine even though you misspelled something. Now that's confusing!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.