Search code examples
javascriptextjsextjs4

Extjs - Resetting events after a window refresh


I have an Ext.window.Window with it's own controller (1 of 2). This window has a button which adds rows to a grid. The number of rows it adds is directly related to the number of events that are triggered after a save ajax call.

How do I reset these events each time the window is brought up? I'm re initializing the window after a successful save.

The window is used often and needs to be closeAction: 'hide'

Code

var controller = this, // Window Controller
    activeRec = controller.activeRecord,
    store = Ext.getStore('Manage'), // Store for the window
    window = Ext.getCmp('window'), // window component
    submitMask = new Ext.LoadMask({target: window, msg: 'Saving data...'}),
    saveButton = Ext.ComponentQuery.query('#am_save_button');

Ext.Ajax.request({
    url: '/save',
    method: 'POST',
    jsonData: jsonChanges,
    scope: this,
    success: function (response, batch) {
        store.load();
        window.record = activeRec;
        controller.init();
        saveButton[0].disable();
        submitMask.hide();
    },
    [...]
});

Console

dispatch
​
<this>: (optimized away)
​
args: (2) […]
​
arguments: Arguments
​
bus: (optimized away)
​
controllers: {…}
​
ev: "click"
​
event: {…}
​
events: (4) […] <-- needs to be '1'
​
i: 0
​
id: "AccountsManagementController"
​
ln: 4
​
me: {…}
​
selector: "accounts_management_grid button[name=\"am_add_account\"]"
​
selectors: {…}
​
target: {…}

Number of events logged


Solution

  • I simplified my success and it is now working. Suspect the init call was to blame:

        success: function (response, batch) {
            window.record = activeRec;
            saveButton[0].disable();
            submitMask.hide();
        },