Search code examples
javascriptonfocus

Auto update data onFocus without refresh


I have a webpage for that allows the user to add attachments (stored in a directory) For this I use a greybox to popup a window and there the user can view add or delete docs as they see fit, this all works fine.

The problem I have is that when the user closes the popup the total of attachments which is displayed on the main page isn't updated and requires a refresh, which I want to avoid. I would like to have this data automatically update preferably when the focus changes back to the main page. I'm on Solaris so I can get the total of files easily its just the display update I need.

All help appreciated

Frankie


Solution

  • In such situations I prefer to handle onPopupClose instead of onFocusChange. After a little search, apparently greybox let you do that by defining a callback function (described here):

    GB_show(caption, url, /*optional*/ height, width, callback_fn) 
    

    So you may write something like this:

    GB_show('Popup', 'popup_url', 500, 500, function() {
        updateTotalAttachmentCount();
    });