cfwindow and javascript gotcha
august 5, 2008 at 5:34pm
in ColdFusion
ok i'll be honest, this is straight out of the docs, but i figure there may be one or two people out there that don't read the docs, so it might be worth passing along.
today i needed to create a <cfwindow> (a tag that i do like, in spite of being on the fence as to whether or not i think the AJAX bits really belong in CF... but that's another post). the source was a page that already existed in another part of the site i was working on. this page made some pretty heavy use of javascript, and not surprisingly, my first efforts to display it resulted in dismal failure.
the error occurred on the following 3 lines of js:
- function Output() { }
- function Proxy() { }
- function Handler() { }
a quick check of the aforementioned docs turned up the following:
If the source attribute specifies a page that defines JavaScript functions, the function definitions on that page must have the following format:
functionName = function(arguments) {function body}
Function definitions that use the following format may not work:
function functionName (arguments) {function body}
so the fix was thankfully much simpler than i had expected it would be. the 3 lines of js above simply needed to be changed to:
- Output = function() { }
- Proxy = function() { }
- Handler = function() { }
...and everything was up and running and worked a treat. hope that might save somebody a few extra minutes of debugging. of course, if you want to walk away with a moral to the story... read the docs. be the docs. love the docs.


# Aug 5, 2008 @ 7:30 PM
# May 31, 2009 @ 1:23 PM
More can be learned from trial, error, frustration and online research, than slogging through a manual that probably isn't structured the way I think in the first place. I really appreciate this post.