Aug
2008
cfwindow and JavaScript Gotcha
Posted 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.


Comments
Add Comment | Subscribe to Comments
-
-
-
Add Comment# Posted todd sharp on 8/5/08 7:30 PM
RTFM FTW
# Posted Charlie on 5/31/09 1:23 PM
Todd - Reading manuals, instructions and maps is overrated. I, for one, prefer to fly by the seat of my pants.
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.
# Posted Ed Northby on 6/29/10 8:47 AM
Great snippet of info!!! I spent way too long trying to figure out what was wrong with my generally correct JavaScript. Thank you for reading the manual for me :)