View Full Version : Window ID changes after move? (appends -ghost)

28 Oct 2013, 5:45 AM
I am currently implementing a taskbar type of interface to manage various windows opened within my ExtJS 4.2.2 application (testing on IE 10). I am having a strange issue though, where the ID of the window is being appended with -ghost after it's moved. This is causing an issue because I store the window's id as part of the toolbar button's itemId (I have to since I can have multiple instances of the same window view). And when I go to close one of these windows the reference back to the toolbar button can't be found, and therefore I can't destroy it along with the window.

Is this -ghost appending normal? I thought that would have been appended only during the move (when the transparent window is show during moving) and removed afterwards. But this doesn't appear to be happening.


So here is my original code that works fine so long as the windows aren't moved: (fires on destroy of a window)

delTaskButton: function (me, eOpts) {
var query = 'toolbar[itemId=taskbar] button[itemId=tbb_' + me.id + ']';
var taskButton = Ext.ComponentQuery.query(query);

and here is the code changed so it does work:

delTaskButton: function (me, eOpts) {
var taskBar = Ext.ComponentQuery.query('toolbar[itemId = taskbar]');
var taskButton = taskBar[0].query('button[itemId=tbb_' + me.id + ']');
taskBar[0].remove(taskButton[0], true);

Now, I thought this had to do with the -ghost being appended, because I could see it in the query variable when it crashed on a null reference. But it turns out that after the window is moved it creates a new linked -ghost window, because I now see the destroy firing twice (my handler is a generic 'window' handler). And it can't find a button for the second window (so that makes sense). I guess I could use the first block if I change the css selector to only handle windows without the -ghost on the end. But the second block is working fine for now (it will just always get called twice).

UPDATE: Better Handling

I still use the second block of code, but my selector it now 'window:not([id$=-ghost])' which means I only get events fired from destroyed windows, and not their associated destroyed ghosts.

Gary Schlosberg
31 Oct 2013, 7:47 PM
Glad to hear you figured this out, and thanks for sharing the solution with the community.