We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40641 ☆ A M B ☆
    • 56 Posts
    I have a MODx.Window which initiates a 'create' action. When that action succeeds the MODx.grid.Grid then updates (I assume automatically, as I can't find any code which actually prompts this action). However, I want to modify this response to do more.

    Where and how do I attach a listener to this Window (or Grid) so that when the action succeeded, I can customise what happens next? (like a typical listener, e.g. listeners: { 'success' {fn:function() { Ext.getCmp('modx-layout').refreshTrees(); },scope:this} } )

    Window:
    delimiter.window.CreateCourse = function(config) { 
        config = config || {};
        Ext.applyIf(config,{
            title: 'New Course',
            url: delimiter.config.connectorUrl,
            baseParams: { action: 'futurefit/course/create' },
            fields: [{
                xtype: 'textfield'
                ,fieldLabel: 'Reference'
                ,name: 'reference'
                ,width: 200
                ,allowBlank: false
            },{
                xtype: 'textfield'
                ,fieldLabel: 'Name'
                ,name: 'name'
                ,width: 420
                ,allowBlank: false
            },{
                xtype: 'textfield'
                ,fieldLabel: 'Description'
                ,name: 'description'
                ,width: 420
            },{
                xtype: 'textfield'
                ,fieldLabel: 'Price (£)'
                ,name: 'price'
                ,width: 100
                ,allowBlank: false
            },{
                xtype: 'textfield'
                ,fieldLabel: 'Admin Fee (£)'
                ,name: 'admin_charge'
                ,width: 100
                ,allowBlank: false
            },{
                xtype: 'checkbox'
                ,fieldLabel: 'Create Page'
                ,name: 'add_update_resource'
                ,inputValue: 1
                ,checked: true
            }]
        });
        delimiter.window.CreateCourse.superclass.constructor.call(this,config);
    };
    Ext.extend(delimiter.window.CreateCourse,MODx.Window);
    Ext.reg('delimiter-window-create-course',delimiter.window.CreateCourse);


    Grid tbar:
        tbar: [{
                xtype: 'textfield'
                ,id: 'delimiter-search-course'
                ,emptyText: 'Search...'
                ,listeners: {
                    'change': {fn:this.search,scope:this}
                    ,'render': {fn: function(cmp) {
                        new Ext.KeyMap(cmp.getEl(), {
                            key: Ext.EventObject.ENTER
                            ,fn: function() {
                                this.fireEvent('change',this);
                                this.blur();
                                return true;
                            }
                            ,scope: cmp
                        });
                    },scope:this}
                }
            },{
                text: 'New Course',
                handler: { xtype: 'delimiter-window-create-course' , blankValues: false }
            }]
      • 8386 ☆ A M B ☆
      • 160 Posts
      Have you tried this:

      tbar: [{
              xtype: 'textfield'
              ,id: 'delimiter-search-course'
              ,emptyText: 'Search...'
              ,listeners: {
                  'change': {fn:this.search,scope:this}
                  ,'render': {fn: function(cmp) {
                      new Ext.KeyMap(cmp.getEl(), {
                          key: Ext.EventObject.ENTER
                          ,fn: function() {
                              this.fireEvent('change',this);
                              this.blur();
                              return true;
                          }
                          ,scope: cmp
                      });
                  },scope:this}
              }
          },{
              text: 'New Course',
              handler: { 
                  xtype: 'delimiter-window-create-course', 
                  blankValues: false,
                  listeners: {
                      'success': {fn: this.success, scope:this}
                  }
              }
          }]
      
        • 40641 ☆ A M B ☆
        • 56 Posts
        Worked perfectly. Thanks!