Dustin,
I do not mean to be rude, but if you use firebug to inspect the div elements
that are created by CFWindow. The normal getElemenyByID('WindowName'), will
return null if it is not defined.
Also you never said if you are doing this dynamically, in other words you
are using JS to create the windows when needed. The reason I said this
before is because as soon as you do <cfwindow> the div element for the
window is created and is in the dom, to be referenced.
I think you should read my posts a little more carefully.
Also you could refactor your code to something like this.
Function Test() {
handleCFWindow('Window1');
handleCFWindow('Window2');
}
handleCFWindow(/* String */ WindowName)
{
If(document.getElementById(WindowName) {
var w = ColdFusion.Window.getWindowObject(WindowName);
w.on('move',setCoordsTODAYAT,w);
w.on('hide',closeWindowTODAYAT,w);
}
}
But like I stated above if cfwindow is used on a page, then that div element
will be there anyway.
Andrew Scott
Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613 9015 8628
Mobile: 0404 998 273
-----Original Message-----
From: Dustin Snell [mailto:[EMAIL PROTECTED]
Sent: Thursday, 20 December 2007 6:10 AM
To: CF-Talk
Subject: Re: Multple CFWINDOWS - cannot identify - 2nd try
For anyone else who wants to do this, I got it working finally. But it
required the use of a try catch block to ignore the exception caused when
you try to ColdFusion.Window.getWindowObject(x) on a window that may or may
not exist. I was unable to find an elegant method to check if a window
exists by name. Also, I had to create a dedicated event-handler for each
window, because if they all fire the same event, no identifiable information
seems to be be passed with the window (most notably, the name).
So the code (which is invoked via AjaxOnLoad()) is clunky, but works and
looks like this:
moveListener = function()
{
if (ColdFusion.Window != null)
{
try {
var w =
ColdFusion.Window.getWindowObject('todayAtWindow');
w.on('move',setCoordsTODAYAT,w);
w.on('hide',closeWindowTODAYAT,w);
} catch (e) {
// ignore it
}
try {
var w = ColdFusion.Window.getWindowObject('searcher');
w.on('move',setCoordsSEARCHER,w);
w.on('hide',closeWindowSEARCHER,w);
} catch (e) {
// ignore it
}
}
}
setCoordsTODAYAT = function(ob,x,y)
{
Set_Cookie('TODAYATWINDOW_X', x, 10, '/', '', '');
Set_Cookie('TODAYATWINDOW_Y', y, 10, '/', '', '');
}
closeWindowTODAYAT = function(ob)
{
Set_Cookie('TODAYATWINDOW_SHOW', false, 10, '/', '', '');
}
setCoordsSEARCHER = function(ob,x,y)
{
Set_Cookie('SEARCHERWINDOW_X', x, 10, '/', '', '');
Set_Cookie('SEARCHERWINDOW_Y', y, 10, '/', '', '');
}
closeWindowSEARCHER = function(ob)
{
Set_Cookie('SEARCHERWINDOW_SHOW', false, 10, '/', '', '');
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295154
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4