Skip to main content
Inspiring
February 22, 2011
Question

ColdFusion.Window (onHide - destroy)

  • February 22, 2011
  • 2 replies
  • 1533 views

Hello All, I have what seems like a simple need.

NEED: To destroy a window when it's closed.(so that any subsiquent opening of that window will have fresh content)

The window is created using ColdFusion.Window.create

1) I'd assume that"refreshOnShow:true" argument would FORCE this to happen when the window goes form hidden to shown... but alas - this does NOT seem to happen.

2) so now i think I need to force the window to be destroyed when it is hidden....removing it from memory.

The problem I'm having is that - according to the CF DEBUGGER - IT LOOKS like the onHide function is executing BEFORE the create function

--- here is the debug screen ---

window:global: uncaught exception: ColdFusion.Window.onHide: Window not found, id: My_Report (, line 0)

error:http: ColdFusion.Window.onHide: Window not found, id: My_Report

info:widget: Window shown, id: WIN_Report

--- end debug ---

Here is my code...Clearly, the create and show functions are 'coded' BEFORE the onHide...and should (in my mind) be created by the time the onHide line gets parsed....

--- my code ---

    // REPORT CONFIG
    var DRconfig =  {
        height:650,width:1120,center:true,refreshOnShow:true,modal:true,closable:true,draggable:true,initshow:false,resizable:false
    }
   
    // CREATE AND SHOW REPORT WINDOW
    function popupReport() {
        ColdFusion.Window.create('My_Report', 'My Report', 'reports/myreport.cfm', DRconfig);

        ColdFusion.Window.show('My_Report');
       
        ColdFusion.Window.onHide('My_Report',destroyWIN('My_Report'));
    }

    // DESTROY THE WINDOW
    function destroyWIN(x) {
        ColdFusion.Window.destroy(x,true)
    }

---

THank for helping...

If someone has a BETTER way of achieving my needs - please share.

    This topic has been closed for replies.

    2 replies

    jpmyobAuthor
    Inspiring
    February 22, 2011

    OK, nothing like answering your own question....

    the onHide function CANNOT exist WITHIN the function that creates the window...

    it can exist as a stand alone event handeler...so THIS works...

    // CREATE AND SHOW REPORT WINDOW
        function popupReport() {
            ColdFusion.Window.create('My_Report', 'My Report', 'reports/myreport.cfm', DRconfig);

            ColdFusion.Window.show('My_Report');
        }

    // DESTROY THE WINDOW
        function destroyWIN(x) {
            ColdFusion.Window.destroy(x,true)
        }

    ColdFusion.Window.onHide('My_Report',destroyWIN('My_Report'));

    HOWEVER - looking at the debug output - I STILL GET AN ERROR

    from THIS simple code...(it doesn't affect the page action, the error only appears in the debug)....thoughts?

    // CREATE AND SHOW REPORT WINDOW
         function popupReport() {
             ColdFusion.Window.create('My_Report', 'My Report', 'reports/myreport.cfm', DRconfig);

            ColdFusion.Window.show('My_Report');
        }

    --- debug ---

    info:widget: Creating window: My_Report

    error:http: ColdFusion.Window.getWindowObject: No window exists by the name My_Report

    --- end ---

    jpmyobAuthor
    Inspiring
    February 22, 2011

    OOPS - the line in debug that says

    "info:widget: Window shown, id: WIN_Report"

    Should read:
    "info:widget: Window shown, id: My_Report"

    THIS is NOT the issue... to those with a keen eye, sorry to include a typo... please be assured the windo name IS consistent throughout - THAT IS NOT THE ISSUE... thanks....