views:

183

answers:

2

Hi All,

Having an issue here that I have tried everything I can think of but cant get it to work. I have a page with a link that creates a cfwindow like so

function create_window(ID){
    var config = new Object();
    config.modal=true;
    config.center=true;
    config.height=775;
    config.width=700;
    config.resizable=false;
    config.closable=false;
    config.draggable=false;
    config.refreshonshow=true;

    ColdFusion.Window.create('newWindow','Window Title', '/source/url'+ID, config)

The window is created and the URL has the ID parsed to it that is used for displaying the correct item in the window. This all works fine.

The problem is when I try and close the window and open a new window with a different item being displayed, the URL is not changed. I realise that this is because the window is being hidden, and not destroyed, and therefore it is the same window being opened. So I have created an onHide event handler to destroy the window like so.

function showItemDetails(){
    var ID=document.getElementById("sList").value       
    create_window(ID);
    ColdFusion.Window.onHide('newWindow', refreshList);
}

function refreshList(){
    ColdFusion.bindHandlerCache['sList'].call();  
    ColdFusion.Window.destroy('newWindow',true);
}

Now when I close the window Firebug is returning the error "ColdFusion.Window.destroy is not a function" (In IE the error is "Object doesn't support this property or method"). I have made sure we are running the latest version of ColdFusion 8.01 on the server (as I know that .destroy wasnt added until 8.01) and have applied the latest hotfixes to the server as well.

Any ideas?

A: 

EDIT: Try this instead:

function refreshList(){
    ColdFusion.bindHandlerCache['sList'].call();
    var newWindow = ColdFusion.Window.getWindowObject('newWindow');
    newWindow.close();
}

I think this is closer, per Adobe's docs...

Josh
Unfortunately that doesnt work, as I receive a 'newWindow is undefined' error when closing the window. Thanks for the suggestion though.
Ryan French
OK. I'm not a ColdFusion expert but I posted a new idea. Let me know if that works?
Josh
Thanks again, still not working. Now Firebug is informing me that newWindow.close() is not a function. I have a feeling its something simple as I know from everything I have read that the destroy method is the one I should be using, it just doesnt seem to be working with my server.
Ryan French
Well, I had a space between "ColdFusion.Window." and "getWindowObject(", did you realize that was an error? If so, try `newWindow.destroy()` instead of `newWindow.close()`...
Josh
Or try: `ColdFusion.Window.hide('newWindow')`
Josh
+2  A: 

Unfortunately, ColdFusion.Window.destroy() doesn't really destroy is a known bug. I'm not sure they've fixed it in CF9 or not, but it was definitely left unfixed in CF8.

Use ColdFusion.navigate() as a workaround. Instead of destroying the window, reuse the same window and navigate it to some other URL.

Henry
Thank you. I managed to get this working in the end by using a try/catch block that checked to see if it could get the window using ColdFusion.Window.getWindowObject('newWindow'), and if it didnt result in an error I used ColdFusion.navigate to redirect the window and then showed it, otherwise if there was an error it created the window.
Ryan French