简体   繁体   中英

How to Add a Button Click event on Controller of EXTJS MVC

I am trying to develop an application using Ext JS. so far I have developed a Viewport with border layout and I have north region, south region done. in the center region i have multiple panel such 1. for search the data. 2. input the data task list (a form) and on the next panel to this I have displayed the grid. Following to that panel I have a Button which should listen to click event to brought up the form to the user.

For that event handeling my controller looks like this:

    this.control({
       'viewport button [action=add]':{
    click: this. addData},
addData : function(button){
consol.log('the add button was clicked');
}
    .......

Now if i click the button in the page where the button has been displayed its not responding anything following is the structure code i have for the viewport:

launch : function() {
    Ext.create('Ext.container.Viewport', {
        layout : 'border',
        autoScroll : true,
        items : [{
            region: 'north',
            .......
        },{
            region: 'west',
            ..............
        },{
            region: 'center',
            items:[{
                xtype: 'panel',
                ..............
            },{
                xtype: 'panel',
                ............
            },{
                xtype: 'userlist' 
            },{
                xtype: 'button',
                 text: 'Add',
                 action: 'add'
            }]
        }]

Any help would be highly Appreciated

Remove the space between button and [action=add] in your selector:

this.control({
   'viewport button[action=add]': {
        click: this. addData
    },
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM