2

I create a window containing grids that send off ajax requests. Now, I immediatley close the window again before the grids are fully created and the ajax requests return.

I have two problems:

  • My components within a window are still "alive" after a window is destroyed

Chrome console lists them. Although my window has the autoDestroy: true the gridpanel and store are still existing after the window is closed. When closed, the destroy event is fired. Docs say, all components under the window should be destroyed.

  • Then my callbacks finally return and get executed but the window is destroyed

The problem is, that the callbacks try to reconfigure a grid that has no more store attached.

Error: Uncaught TypeError: Cannot call method 'getCount' of null Table.js:500 (/lib/extjs/src/view/Table.js

How can I stop the callbacks from processing if my window is destroyed?

Shlomo
  • 3,880
  • 8
  • 50
  • 82

1 Answers1

5

Registering the events with mon so that they get removed when the listening object get destroyed. Alternatively you may:

  • remove them manually within the destroy() method
  • check within the callback for methods or properties that may not exist to skip them

Edit

There are some more things that you can do

  1. check if the destroy() methods of the grids get called
  2. abort all request by calling Ext.Ajax.abortAll() (before the window close)
  3. abort just specific requestst by calling Ext.Ajax.abort(request) (before the window close)

I recommend to use option 2. because it should be the safest.

Edit 2

To take a look at all running request you need to look at the private requests property of Ext.data.Connection from which Ext.Ajax extend. requests is of type object and will contain a property (the request Id) for each request that is currently running.

sra
  • 23,820
  • 7
  • 55
  • 89
  • Thanks. I have plenty of children in that main view. Is there no other way? Tried `view.removeAll()` – Shlomo Jul 11 '13 at 13:49
  • Thanks. The `abortAll` looks great. I will take a look at it. However I would have to know what requests are out there all the time... :/ – Shlomo Jul 11 '13 at 15:03
  • @Indianer That is correct. But you can get a info of how many request are currently running, see my edit. – sra Jul 12 '13 at 06:26